Skip to content

Commit

Permalink
Merge pull request #71 from gilhanan/testing-html-toasts
Browse files Browse the repository at this point in the history
test(toast): render HTML
  • Loading branch information
akserg authored Jun 12, 2017
2 parents 9ce6a90 + b0a3f92 commit deac037
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 deac037

Please sign in to comment.