-
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.
BREAKING CHANGE: NbBadgeComponent status static fields removed. STATUS_PRIMARY, STATUS_INFO, STATUS_SUCCESS, STATUS_WARNING, STATUS_DANGER. NbBadgeComponent position static fields replaced with NbBadgePosition type. Removed properties: TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, TOP_START, TOP_END, BOTTOM_START, BOTTOM_END. Badge status class now set on host element NbBadgeComponent 'positionClass' getter removed. Badge position class set on host element. Position class names prefixed with 'position-'. Following theme properties were renamed: badge-fg-text -> badge-[status]-text-color badge-primary-bg-color -> badge-primary-background-color badge-success-bg-color -> badge-success-background-color badge-info-bg-color -> badge-info-background-color badge-warning-bg-color -> badge-warning-background-color badge-danger-bg-color -> badge-danger-background-color
- Loading branch information
Showing
15 changed files
with
316 additions
and
144 deletions.
There are no files selected for viewing
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
111 changes: 111 additions & 0 deletions
111
src/framework/theme/components/badge/badge.component.spec.ts
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,111 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { NbBadgeComponent, NbBadgeModule, NbBadgePosition, NbComponentStatus } from '@nebular/theme'; | ||
|
||
describe('NbBadgeComponent', () => { | ||
let fixture: ComponentFixture<NbBadgeComponent>; | ||
let badgeComponent: NbBadgeComponent; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ NbBadgeModule ], | ||
}); | ||
|
||
fixture = TestBed.createComponent(NbBadgeComponent); | ||
badgeComponent = fixture.componentInstance; | ||
}); | ||
|
||
it(`should contain text set to 'text' input`, () => { | ||
const text = 'random badge text'; | ||
badgeComponent.text = text; | ||
fixture.detectChanges(); | ||
|
||
expect(fixture.debugElement.nativeElement.textContent).toEqual(text); | ||
}); | ||
|
||
it('should has primary status by default', () => { | ||
expect(badgeComponent.status).toEqual('primary'); | ||
}); | ||
|
||
it('should set status class', () => { | ||
const statuses: NbComponentStatus[] = [ 'primary', 'success', 'info', 'warning', 'danger' ]; | ||
|
||
for (const status of statuses) { | ||
badgeComponent.status = status; | ||
fixture.detectChanges(); | ||
|
||
expect(fixture.debugElement.classes[`status-${status}`]).toEqual(true); | ||
} | ||
}); | ||
|
||
it(`should has 'top' class if position contains 'top'`, () => { | ||
const topPositions: NbBadgePosition[] = [ 'top end', 'top left', 'top right', 'top start' ]; | ||
|
||
for (const position of topPositions) { | ||
badgeComponent.position = position; | ||
fixture.detectChanges(); | ||
|
||
expect(badgeComponent.top).toEqual(true); | ||
expect(fixture.debugElement.classes['position-top']).toEqual(true); | ||
} | ||
}); | ||
|
||
it(`should has 'right' class if position contains 'right'`, () => { | ||
const rightPositions: NbBadgePosition[] = [ 'top right', 'bottom right' ]; | ||
|
||
for (const position of rightPositions) { | ||
badgeComponent.position = position; | ||
fixture.detectChanges(); | ||
|
||
expect(badgeComponent.right).toEqual(true); | ||
expect(fixture.debugElement.classes['position-right']).toEqual(true); | ||
} | ||
}); | ||
|
||
it(`should has 'bottom' class if position contains 'bottom'`, () => { | ||
const bottomPositions: NbBadgePosition[] = [ 'bottom end', 'bottom left', 'bottom right', 'bottom start' ]; | ||
|
||
for (const position of bottomPositions) { | ||
badgeComponent.position = position; | ||
fixture.detectChanges(); | ||
|
||
expect(badgeComponent.bottom).toEqual(true); | ||
expect(fixture.debugElement.classes['position-bottom']).toEqual(true); | ||
} | ||
}); | ||
|
||
it(`should has 'left' class if position contains 'left'`, () => { | ||
const leftPositions: NbBadgePosition[] = [ 'top left', 'bottom left' ]; | ||
|
||
for (const position of leftPositions) { | ||
badgeComponent.position = position; | ||
fixture.detectChanges(); | ||
|
||
expect(badgeComponent.left).toEqual(true); | ||
expect(fixture.debugElement.classes['position-left']).toEqual(true); | ||
} | ||
}); | ||
|
||
it(`should has 'start' class if position contains 'start'`, () => { | ||
const startPositions: NbBadgePosition[] = [ 'top start', 'bottom start' ]; | ||
|
||
for (const position of startPositions) { | ||
badgeComponent.position = position; | ||
fixture.detectChanges(); | ||
|
||
expect(badgeComponent.start).toEqual(true); | ||
expect(fixture.debugElement.classes['position-start']).toEqual(true); | ||
} | ||
}); | ||
|
||
it(`should has 'end' class if position contains 'end'`, () => { | ||
const endPositions: NbBadgePosition[] = [ 'top end', 'bottom end' ]; | ||
|
||
for (const position of endPositions) { | ||
badgeComponent.position = position; | ||
fixture.detectChanges(); | ||
|
||
expect(badgeComponent.end).toEqual(true); | ||
expect(fixture.debugElement.classes['position-end']).toEqual(true); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.