Skip to content

Commit 86a4908

Browse files
committed
test(button): adding a test for checking the correct type CSS class #5404
1 parent 0e6607e commit 86a4908

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

projects/igniteui-angular/src/lib/directives/button/button.directive.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,33 @@ describe('IgxButton', () => {
108108
verifyDisplayDensity(fabButton, fabButtonDOM, 'fab', DisplayDensity.cosy);
109109
verifyDisplayDensity(iconButton, iconButtonDOM, 'icon', DisplayDensity.cosy);
110110
});
111+
112+
it('Should set the correct CSS class on the element using the "type" input', () => {
113+
const fixture = TestBed.createComponent(InitButtonComponent);
114+
fixture.detectChanges();
115+
const theButton = fixture.componentInstance.button;
116+
const theButtonNativeEl = theButton.nativeElement;
117+
118+
theButton.type = 'raised';
119+
fixture.detectChanges();
120+
expect(theButtonNativeEl.classList).toEqual('igx-button--raised');
121+
122+
theButton.type = 'outlined';
123+
fixture.detectChanges();
124+
expect(theButtonNativeEl.classList).toEqual('igx-button--outlined');
125+
126+
theButton.type = 'fab';
127+
fixture.detectChanges();
128+
expect(theButtonNativeEl.classList).toEqual('igx-button--fab');
129+
130+
theButton.type = 'icon';
131+
fixture.detectChanges();
132+
expect(theButtonNativeEl.classList).toEqual('igx-button--icon');
133+
134+
theButton.type = 'flat';
135+
fixture.detectChanges();
136+
expect(theButtonNativeEl.classList).toEqual('igx-button--flat');
137+
});
111138
});
112139

113140
@Component({
@@ -117,6 +144,8 @@ describe('IgxButton', () => {
117144
</span>`
118145
})
119146
class InitButtonComponent {
147+
@ViewChild(IgxButtonDirective, { read: IgxButtonDirective })
148+
button: IgxButtonDirective;
120149
}
121150

122151
@Component({

0 commit comments

Comments
 (0)