Skip to content

Commit f386601

Browse files
Copilotkdinev
andcommitted
Add tests for badge size and dot type features
Co-authored-by: kdinev <[email protected]>
1 parent 5c52168 commit f386601

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

projects/igniteui-angular/src/lib/badge/badge.component.spec.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, ViewChild } from '@angular/core';
22
import { TestBed, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
4-
import { IgxBadgeComponent, IgxBadgeType } from './badge.component';
4+
import { IgxBadgeComponent, IgxBadgeType, IgxBadgeSize } from './badge.component';
55

66
describe('Badge', () => {
77
beforeEach(waitForAsync(() => {
@@ -11,7 +11,9 @@ describe('Badge', () => {
1111
InitBadgeWithDefaultsComponent,
1212
InitBadgeWithIconComponent,
1313
IgxBadgeComponent,
14-
InitBadgeWithIconARIAComponent
14+
InitBadgeWithIconARIAComponent,
15+
InitBadgeWithSizeComponent,
16+
InitBadgeWithDotTypeComponent
1517
]
1618
}).compileComponents();
1719
}));
@@ -87,6 +89,33 @@ describe('Badge', () => {
8789
const container = fixture.nativeElement.querySelectorAll('.igx-badge')[0];
8890
expect(container.getAttribute('aria-roledescription')).toMatch(expectedDescription);
8991
});
92+
93+
it('Initializes badge with size', () => {
94+
const fixture = TestBed.createComponent(InitBadgeWithSizeComponent);
95+
fixture.detectChanges();
96+
const badge = fixture.componentInstance.badge;
97+
const domBadge = fixture.debugElement.query(By.css('igx-badge')).nativeElement;
98+
99+
expect(badge.size).toBe(IgxBadgeSize.LARGE);
100+
expect(domBadge.style.getPropertyValue('--component-size')).toBe('var(--ig-size-large)');
101+
});
102+
103+
it('Initializes badge with default size', () => {
104+
const fixture = TestBed.createComponent(InitBadgeWithDefaultsComponent);
105+
fixture.detectChanges();
106+
const badge = fixture.componentInstance.badge;
107+
108+
expect(badge.size).toBe(IgxBadgeSize.MEDIUM);
109+
});
110+
111+
it('Initializes badge with dot type', () => {
112+
const fixture = TestBed.createComponent(InitBadgeWithDotTypeComponent);
113+
fixture.detectChanges();
114+
const badge = fixture.componentInstance.badge;
115+
116+
expect(badge.type).toBe(IgxBadgeType.DOT);
117+
expect(fixture.debugElement.query(By.css('.igx-badge--dot'))).toBeTruthy();
118+
});
90119
});
91120

92121
@Component({
@@ -120,3 +149,19 @@ class InitBadgeWithIconComponent {
120149
class InitBadgeWithIconARIAComponent {
121150
@ViewChild(IgxBadgeComponent, { static: true }) public badge: IgxBadgeComponent;
122151
}
152+
153+
@Component({
154+
template: `<igx-badge size="large" value="10"></igx-badge>`,
155+
imports: [IgxBadgeComponent]
156+
})
157+
class InitBadgeWithSizeComponent {
158+
@ViewChild(IgxBadgeComponent, { static: true }) public badge: IgxBadgeComponent;
159+
}
160+
161+
@Component({
162+
template: `<igx-badge type="dot"></igx-badge>`,
163+
imports: [IgxBadgeComponent]
164+
})
165+
class InitBadgeWithDotTypeComponent {
166+
@ViewChild(IgxBadgeComponent, { static: true }) public badge: IgxBadgeComponent;
167+
}

0 commit comments

Comments
 (0)