license import { Observable , of } from 'rxjs' ; import { defaultIfEmpty } from 'rxjs/operators' ; import { asyncTest } from '../test-util' ; describe ( 'Observable.defaultIfEmpty' , ( ) => { let log ; let observable1 ; beforeEach ( ( ) => { log = [ ] ; } ) ; it ( 'defaultIfEmpty func callback should run in the correct zone' , asyncTest ( ( done ) => { const constructorZone1 = Zone . current . fork ( { name : 'Constructor Zone1' } ) ; const subscriptionZone = Zone . current . fork ( { name : 'Subscription Zone' } ) ; observable1 = constructorZone1 . run ( ( ) => { return of ( ) . pipe ( defaultIfEmpty ( 'empty' ) ) ; } ) ; subscriptionZone . run ( ( ) => { observable1 . subscribe ( ( result ) => { log . push ( result ) ; expect ( Zone . current . name ) . toEqual ( subscriptionZone . name ) ; } , ( ) => { fail ( 'should not call error' ) ; } , ( ) => { log . push ( 'completed' ) ; expect ( Zone . current . name ) . toEqual ( subscriptionZone . name ) ; expect ( log ) . toEqual ( [ 'empty' , 'completed' ] ) ; done ( ) ; } ) ; } ) ; } , Zone . root ) ) ; } ) ;