Skip to content

Commit

Permalink
test(toast): render HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
gilhanan committed Mar 2, 2017
1 parent ee65355 commit b0a3f92
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/toast.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,38 @@ describe('ToastComponent', () => {
componentFixture.componentInstance.toast.title = null;
componentFixture.componentInstance.toast.msg = null;
});

it('should render HTML in message', () => {
const element = componentFixture.nativeElement;
expect(element.querySelector('.toast-text')).toBeNull();

componentFixture.componentInstance.toast.msg = '<strong style="color: #ABCDEF">msg</strong>';
componentFixture.detectChanges();

expect(element.querySelector('.toast-text')).not.toBeNull();
expect(element.querySelector('.toast-msg')).not.toBeNull();
expect(element.querySelector('.toast-msg').textContent).toBe('msg');
expect(element.querySelector('.toast-msg strong')).not.toBeNull();
expect(element.querySelector('.toast-msg strong').style.color).toBeTruthy();

componentFixture.componentInstance.toast.title = null;
componentFixture.componentInstance.toast.msg = null;
});

it('should render HTML in title', () => {
const element = componentFixture.nativeElement;
expect(element.querySelector('.toast-text')).toBeNull();

componentFixture.componentInstance.toast.title = '<strong style="color: #ABCDEF">title</strong>';
componentFixture.detectChanges();

expect(element.querySelector('.toast-text')).not.toBeNull();
expect(element.querySelector('.toast-title')).not.toBeNull();
expect(element.querySelector('.toast-title').textContent).toBe('title');
expect(element.querySelector('.toast-title strong')).not.toBeNull();
expect(element.querySelector('.toast-title strong').style.color).toBeTruthy();

componentFixture.componentInstance.toast.title = null;
componentFixture.componentInstance.toast.msg = null;
});
});

0 comments on commit b0a3f92

Please sign in to comment.