11import { Component , ViewChild } from '@angular/core' ;
22import {
3- async ,
3+ waitForAsync ,
44 TestBed ,
55 fakeAsync ,
66 tick ,
@@ -14,17 +14,16 @@ import {
1414} from './toast.component' ;
1515import { configureTestSuite } from '../test-utils/configure-suite' ;
1616
17- describe ( 'IgxToast' , ( ) => {
17+ fdescribe ( 'IgxToast' , ( ) => {
1818 configureTestSuite ( ) ;
19- beforeAll ( async ( ( ) => {
19+ beforeAll ( waitForAsync ( ( ) => {
2020 TestBed . configureTestingModule ( {
2121 declarations : [ ToastInitializeTestComponent ] ,
2222 imports : [ BrowserAnimationsModule , IgxToastModule ] ,
2323 } ) . compileComponents ( ) ;
2424 } ) ) ;
2525
2626 const baseClass = 'igx-toast' ;
27- const activeClass = 'igx-toast--active' ;
2827 let fixture : ComponentFixture < ToastInitializeTestComponent > ;
2928 let toast : IgxToastComponent ;
3029
@@ -43,7 +42,6 @@ describe('IgxToast', () => {
4342 expect ( toast . displayTime ) . toBe ( 4000 ) ;
4443 expect ( toast . autoHide ) . toBeTruthy ( ) ;
4544 expect ( toast . isVisible ) . toBeTruthy ( ) ;
46- expect ( domToast . classList ) . toContain ( activeClass ) ;
4745
4846 toast . id = 'customToast' ;
4947 fixture . detectChanges ( ) ;
@@ -79,28 +77,52 @@ describe('IgxToast', () => {
7977 expect ( toast . isVisible ) . toBeTruthy ( ) ;
8078 } ) ) ;
8179
82- it ( 'visibility is updated by the toggle() method' , ( ) => {
83- spyOn ( toast . onShowing , 'emit' ) ;
84- spyOn ( toast . onShown , 'emit' ) ;
85- spyOn ( toast . onHiding , 'emit' ) ;
86- spyOn ( toast . onHidden , 'emit' ) ;
80+ it ( 'should emit onShowing when super onOpening is fired' , waitForAsync ( ( ) => {
81+ toast . show ( ) ;
82+
83+ toast . onOpening . subscribe ( ( ) => {
84+ spyOn ( toast . onShowing , 'emit' ) ;
85+ expect ( toast . onShowing . emit ) . toHaveBeenCalled ( ) ;
86+ } ) ;
87+ } ) ) ;
8788
89+ it ( 'should emit onShown when super onAppended is fired' , waitForAsync ( ( ) => {
8890 toast . show ( ) ;
89- expect ( toast . isVisible ) . toBe ( true ) ;
9091
91- expect ( toast . onShowing . emit ) . toHaveBeenCalledTimes ( 1 ) ;
92- expect ( toast . onShown . emit ) . toHaveBeenCalledTimes ( 1 ) ;
93- expect ( toast . onHiding . emit ) . toHaveBeenCalledTimes ( 0 ) ;
94- expect ( toast . onHidden . emit ) . toHaveBeenCalledTimes ( 0 ) ;
92+ toast . onAppended . subscribe ( ( ) => {
93+ spyOn ( toast . onShown , 'emit' ) ;
94+ expect ( toast . onShown . emit ) . toHaveBeenCalled ( ) ;
95+ } ) ;
96+ } ) ) ;
97+
98+ it ( 'should emit onHiding when super onClosing is fired' , waitForAsync ( ( ) => {
99+ toast . isVisible = true ;
100+ toast . hide ( ) ;
101+
102+ toast . onClosing . subscribe ( ( ) => {
103+ spyOn ( toast . onHiding , 'emit' ) ;
104+ expect ( toast . onHiding . emit ) . toHaveBeenCalled ( ) ;
105+ } ) ;
106+ } ) ) ;
95107
108+ it ( 'should emit onHidden when super onClosed is fired' , waitForAsync ( ( ) => {
109+ toast . isVisible = true ;
110+ toast . hide ( ) ;
111+
112+ toast . onClosed . subscribe ( ( ) => {
113+ spyOn ( toast . onHidden , 'emit' ) ;
114+ expect ( toast . onHidden . emit ) . toHaveBeenCalled ( ) ;
115+ } ) ;
116+ } ) ) ;
117+
118+ it ( 'visibility is updated by the toggle() method' , waitForAsync ( ( ) => {
119+ toast . isVisible = true ;
96120 toast . toggle ( ) ;
97- expect ( toast . isVisible ) . toBe ( false ) ;
98121
99- expect ( toast . onShowing . emit ) . toHaveBeenCalledTimes ( 1 ) ;
100- expect ( toast . onShown . emit ) . toHaveBeenCalledTimes ( 1 ) ;
101- expect ( toast . onHiding . emit ) . toHaveBeenCalledTimes ( 1 ) ;
102- expect ( toast . onHidden . emit ) . toHaveBeenCalledTimes ( 1 ) ;
103- } ) ;
122+ toast . onHiding . subscribe ( ( ) => {
123+ expect ( toast . isVisible ) . toEqual ( false ) ;
124+ } ) ;
125+ } ) ) ;
104126
105127 it ( 'can set message through show method' , fakeAsync ( ( ) => {
106128 toast . displayTime = 100 ;
0 commit comments