@@ -16,6 +16,12 @@ import { NotifierTimerService } from '../services/notifier-timer.service';
1616 */
1717describe ( 'Notifier Notification Component' , ( ) => {
1818
19+ // tslint:disable no-any
20+ const fakeAnimation : any = {
21+ onfinish : ( ) => null // We only need this property to be actually mocked away
22+ } ;
23+ // tslint:enable no-any
24+
1925 const testNotification : NotifierNotification = new NotifierNotification ( {
2026 id : 'ID_FAKE' ,
2127 message : 'Lorem ipsum dolor sit amet.' ,
@@ -239,16 +245,13 @@ describe( 'Notifier Notification Component', () => {
239245
240246 // Mock away the Web Animations API
241247 jest . spyOn ( componentFixture . nativeElement , 'animate' ) . mockImplementation ( ( ) => {
242- return {
243- finished : new Promise < undefined > ( ( resolve : ( ) => void , reject : ( ) => void ) => {
244- componentFixture . debugElement . styles [ 'opacity' ] = '1' ; // Fake animation result
245- resolve ( ) ;
246- } )
247- } ;
248+ componentFixture . debugElement . styles [ 'opacity' ] = '1' ; // Fake animation result
249+ return fakeAnimation ;
248250 } ) ;
249251
250252 const showCallback : ( ) => { } = jest . fn ( ) ;
251253 componentInstance . show ( ) . then ( showCallback ) ;
254+ fakeAnimation . onfinish ( ) ;
252255 tick ( ) ;
253256
254257 expect ( componentFixture . debugElement . styles [ 'visibility' ] ) . toBe ( 'visible' ) ;
@@ -298,16 +301,13 @@ describe( 'Notifier Notification Component', () => {
298301
299302 // Mock away the Web Animations API
300303 jest . spyOn ( componentFixture . nativeElement , 'animate' ) . mockImplementation ( ( ) => {
301- return {
302- finished : new Promise < undefined > ( ( resolve : ( ) => void , reject : ( ) => void ) => {
303- componentFixture . debugElement . styles [ 'opacity' ] = '0' ; // Fake animation result
304- resolve ( ) ;
305- } )
306- } ;
304+ componentFixture . debugElement . styles [ 'opacity' ] = '0' ; // Fake animation result
305+ return fakeAnimation ;
307306 } ) ;
308307
309308 const hideCallback : ( ) => { } = jest . fn ( ) ;
310309 componentInstance . hide ( ) . then ( hideCallback ) ;
310+ fakeAnimation . onfinish ( ) ;
311311 tick ( ) ;
312312
313313 expect ( componentFixture . debugElement . styles [ 'opacity' ] ) . toBe ( '0' ) ;
@@ -385,17 +385,14 @@ describe( 'Notifier Notification Component', () => {
385385
386386 // Mock away the Web Animations API
387387 jest . spyOn ( componentFixture . nativeElement , 'animate' ) . mockImplementation ( ( ) => {
388- return {
389- finished : new Promise < undefined > ( ( resolve : ( ) => void , reject : ( ) => void ) => {
390- componentFixture . debugElement . styles [ 'transform' ] =
391- `translate3d( 0, ${ shiftDistance + testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
392- resolve ( ) ;
393- } )
394- } ;
388+ componentFixture . debugElement . styles [ 'transform' ] =
389+ `translate3d( 0, ${ shiftDistance + testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
390+ return fakeAnimation ;
395391 } ) ;
396392
397393 const shiftCallback : ( ) => { } = jest . fn ( ) ;
398394 componentInstance . shift ( shiftDistance , true ) . then ( shiftCallback ) ;
395+ fakeAnimation . onfinish ( ) ;
399396 tick ( ) ;
400397
401398 expect ( componentFixture . debugElement . styles [ 'transform' ] )
@@ -469,17 +466,14 @@ describe( 'Notifier Notification Component', () => {
469466 // Mock away the Web Animations API
470467 const shiftDistance : number = 100 ;
471468 jest . spyOn ( componentFixture . nativeElement , 'animate' ) . mockImplementation ( ( ) => {
472- return {
473- finished : new Promise < undefined > ( ( resolve : ( ) => void , reject : ( ) => void ) => {
474- componentFixture . debugElement . styles [ 'transform' ] =
475- `translate3d( 0, ${ - shiftDistance - testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
476- resolve ( ) ;
477- } )
478- } ;
469+ componentFixture . debugElement . styles [ 'transform' ] =
470+ `translate3d( 0, ${ - shiftDistance - testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
471+ return fakeAnimation ;
479472 } ) ;
480473
481474 const shiftCallback : ( ) => { } = jest . fn ( ) ;
482475 componentInstance . shift ( shiftDistance , true ) . then ( shiftCallback ) ;
476+ fakeAnimation . onfinish ( ) ;
483477 tick ( ) ;
484478
485479 expect ( componentFixture . debugElement . styles [ 'transform' ] )
@@ -553,17 +547,14 @@ describe( 'Notifier Notification Component', () => {
553547 // Mock away the Web Animations API
554548 const shiftDistance : number = 100 ;
555549 jest . spyOn ( componentFixture . nativeElement , 'animate' ) . mockImplementation ( ( ) => {
556- return {
557- finished : new Promise < undefined > ( ( resolve : ( ) => void , reject : ( ) => void ) => {
558- componentFixture . debugElement . styles [ 'transform' ] =
559- `translate3d( 0, ${ - shiftDistance - testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
560- resolve ( ) ;
561- } )
562- } ;
550+ componentFixture . debugElement . styles [ 'transform' ] =
551+ `translate3d( 0, ${ - shiftDistance - testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
552+ return fakeAnimation ;
563553 } ) ;
564554
565555 const shiftCallback : ( ) => { } = jest . fn ( ) ;
566556 componentInstance . shift ( shiftDistance , false ) . then ( shiftCallback ) ;
557+ fakeAnimation . onfinish ( ) ;
567558 tick ( ) ;
568559
569560 expect ( componentFixture . debugElement . styles [ 'transform' ] )
@@ -637,17 +628,14 @@ describe( 'Notifier Notification Component', () => {
637628 // Mock away the Web Animations API
638629 const shiftDistance : number = 100 ;
639630 jest . spyOn ( componentFixture . nativeElement , 'animate' ) . mockImplementation ( ( ) => {
640- return {
641- finished : new Promise < undefined > ( ( resolve : ( ) => void , reject : ( ) => void ) => {
642- componentFixture . debugElement . styles [ 'transform' ] =
643- `translate3d( 0, ${ shiftDistance + testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
644- resolve ( ) ;
645- } )
646- } ;
631+ componentFixture . debugElement . styles [ 'transform' ] =
632+ `translate3d( 0, ${ shiftDistance + testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
633+ return fakeAnimation ;
647634 } ) ;
648635
649636 const shiftCallback : ( ) => { } = jest . fn ( ) ;
650637 componentInstance . shift ( shiftDistance , false ) . then ( shiftCallback ) ;
638+ fakeAnimation . onfinish ( ) ;
651639 tick ( ) ;
652640
653641 expect ( componentFixture . debugElement . styles [ 'transform' ] )
@@ -724,17 +712,14 @@ describe( 'Notifier Notification Component', () => {
724712 // Mock away the Web Animations API
725713 const shiftDistance : number = 100 ;
726714 jest . spyOn ( componentFixture . nativeElement , 'animate' ) . mockImplementation ( ( ) => {
727- return {
728- finished : new Promise < undefined > ( ( resolve : ( ) => void , reject : ( ) => void ) => {
729- componentFixture . debugElement . styles [ 'transform' ] =
730- `translate3d( -50%, ${ shiftDistance + testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
731- resolve ( ) ;
732- } )
733- } ;
715+ componentFixture . debugElement . styles [ 'transform' ] =
716+ `translate3d( -50%, ${ shiftDistance + testNotifierConfig . position . vertical . gap } px, 0 )` ; // Fake animation result
717+ return fakeAnimation ;
734718 } ) ;
735719
736720 const shiftCallback : ( ) => { } = jest . fn ( ) ;
737721 componentInstance . shift ( shiftDistance , true ) . then ( shiftCallback ) ;
722+ fakeAnimation . onfinish ( ) ;
738723 tick ( ) ;
739724
740725 expect ( componentFixture . debugElement . styles [ 'transform' ] )
0 commit comments