Skip to content

Commit 901204b

Browse files
committed
test(igxSnackbar): test that show method can display correctly a message #7156
1 parent ee47d94 commit 901204b

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ describe('IgxSnackbar', () => {
3131

3232
it('should properly initialize properties', () => {
3333
expect(snackbar.id).toContain('igx-snackbar-');
34-
expect(snackbar.message).toBeUndefined();
3534
expect(snackbar.actionText).toBeUndefined();
3635
expect(snackbar.displayTime).toBe(4000);
3736
expect(snackbar.autoHide).toBeTruthy();
@@ -115,8 +114,7 @@ describe('IgxSnackbar with custom content', () => {
115114

116115
it('should display a message, a custom content element and a button', () => {
117116
fixture.componentInstance.text = 'Undo';
118-
snackbar.message = 'Item shown';
119-
snackbar.isVisible = true;
117+
snackbar.show('Item shown');
120118
fixture.detectChanges();
121119

122120
const messageEl = fixture.debugElement.query(By.css('.igx-snackbar__message'));
@@ -136,6 +134,25 @@ describe('IgxSnackbar with custom content', () => {
136134
expect(customContentRect.right <= buttonRect.left).toBe(true, 'The custom element is not on the left of the button');
137135
expect(messageElRect.right <= buttonRect.left).toBe(true, 'The button is not on the right side of the snackbar content');
138136
});
137+
138+
it('should be able to set a message though show method', () => {
139+
snackbar.autoHide = false;
140+
fixture.componentInstance.text = 'Retry';
141+
fixture.detectChanges();
142+
143+
snackbar.show('The message was not send. Would you like to retry?');
144+
fixture.detectChanges();
145+
146+
expect(fixture.nativeElement.querySelector('.igx-snackbar__message').innerText)
147+
.toBe('The message was not send. Would you like to retry? Custom content');
148+
149+
snackbar.show('Another Message?!');
150+
fixture.detectChanges();
151+
152+
expect(snackbar.isVisible).toBe(true);
153+
expect(fixture.nativeElement.querySelector('.igx-snackbar__message').innerText)
154+
.toBe('Another Message?! Custom content');
155+
});
139156
});
140157

141158
@Component({

0 commit comments

Comments
 (0)