-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(badge): add new badge component (#111)
- Loading branch information
Showing
28 changed files
with
892 additions
and
4 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { browser, element, by } from 'protractor'; | ||
import { NbBadgeComponent } from '../src/framework/theme/components/badge/badge.component'; | ||
import badgeTests from './badge.e2e-spec'; | ||
|
||
describe('nb-action', () => { | ||
|
||
beforeEach(() => { | ||
browser.get('#/actions'); | ||
}); | ||
|
||
describe('badge', () => { | ||
const badgeText = '29'; | ||
const badgesConf = { | ||
selector: (i) => `nb-card:nth-child(4) nb-actions nb-action:nth-child(${i + 1}) nb-badge > span`, | ||
badges: [ | ||
{ position: NbBadgeComponent.BOTTOM_LEFT, status: NbBadgeComponent.STATUS_SUCCESS, text: badgeText }, | ||
{ position: NbBadgeComponent.TOP_LEFT, status: NbBadgeComponent.STATUS_DANGER, text: badgeText }, | ||
{ position: NbBadgeComponent.BOTTOM_RIGHT, status: NbBadgeComponent.STATUS_WARNING, text: badgeText }, | ||
{ position: NbBadgeComponent.BOTTOM_LEFT, status: NbBadgeComponent.STATUS_SUCCESS, text: badgeText }, | ||
{ position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_INFO, text: badgeText }, | ||
{ position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_INFO, text: badgeText }, | ||
{ position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_PRIMARY, text: badgeText }, | ||
], | ||
}; | ||
badgeTests(badgesConf); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { element, by } from 'protractor'; | ||
|
||
export default function badgeTests (badgesConfig) { | ||
const { selector, badges } = badgesConfig; | ||
|
||
it('should display badge with correct text', () => { | ||
for (let i = 0; i < badges.length; i++) { | ||
const badgeEl = element(by.css(selector(i))); | ||
expect(badgeEl.getText()).toEqual(badges[i].text); | ||
} | ||
}); | ||
|
||
it('should display badge with correct status', () => { | ||
for (let i = 0; i < badges.length; i++) { | ||
const badgeEl = element(by.css(selector(i))); | ||
expect(badgeEl.getAttribute('class')).toContain(badges[i].status); | ||
} | ||
}); | ||
|
||
it('should display badge in correct position', () => { | ||
for (let i = 0; i < badges.length; i++) { | ||
const badgeEl = element(by.css(selector(i))); | ||
expect(badgeEl.getAttribute('class')).toContain(badges[i].position); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.