license declare function suite ( description , suiteFn ) ; declare function test ( description , testFn ) ; declare function specify ( description , testFn ) ; declare function setup ( fn ) ; declare function teardown ( fn ) ; declare function suiteSetup ( fn ) ; declare function suiteTeardown ( fn ) ; declare function before ( fn ) ; declare function after ( fn ) ; import { ifEnvSupports } from './test-util' ; ifEnvSupports ( 'Mocha' , function ( ) { describe ( 'Mocha BDD-style' , ( ) => { let throwOnAsync = false ; let beforeEachZone = null ; let itZone = null ; const syncZone = Zone . current ; let beforeZone = null ; before ( ( ) => { beforeZone = Zone . current ; } ) ; try { Zone . current . scheduleMicroTask ( 'dontallow' , ( ) : any => null ) ; } catch ( e ) { throwOnAsync = true ; } beforeEach ( ( ) => beforeEachZone = Zone . current ) ; it ( 'should throw on async in describe' , ( ) => { expect ( Zone . currentTask ) . toBeTruthy ( ) ; expect ( throwOnAsync ) . toBe ( true ) ; expect ( syncZone . name ) . toEqual ( 'syncTestZone for Mocha.describe' ) ; itZone = Zone . current ; } ) ; afterEach ( ( ) => { let zone = Zone . current ; expect ( zone . name ) . toEqual ( 'ProxyZone' ) ; expect ( beforeEachZone ) . toBe ( zone ) ; expect ( itZone ) . toBe ( zone ) ; } ) ; after ( ( ) => { expect ( beforeZone ) . toBe ( Zone . current ) ; } ) ; } ) ; suite ( 'Mocha TDD-style' , ( ) => { let testZone = null ; let beforeEachZone = null ; let suiteSetupZone = null ; suiteSetup ( ( ) => { suiteSetupZone = Zone . current ; } ) ; setup ( ( ) => { beforeEachZone = Zone . current ; } ) ; test ( 'should run in Zone with "test"-syntax in TDD-mode' , ( ) => { testZone = Zone . current ; expect ( Zone . currentTask ) . toBeTruthy ( ) ; expect ( testZone . name ) . toEqual ( 'ProxyZone' ) ; } ) ; specify ( 'test should run in Zone with "specify"-syntax in TDD-mode' , ( ) => { testZone = Zone . current ; expect ( Zone . currentTask ) . toBeTruthy ( ) ; expect ( testZone . name ) . toEqual ( 'ProxyZone' ) ; } ) ; teardown ( ( ) => { expect ( Zone . current . name ) . toEqual ( 'ProxyZone' ) ; expect ( beforeEachZone ) . toBe ( Zone . current ) ; expect ( testZone ) . toBe ( Zone . current ) ; } ) ; suiteTeardown ( ( ) => { expect ( suiteSetupZone ) . toBe ( Zone . current ) ; } ) ; } ) ; describe ( 'return promise' , ( ) => { let log ; beforeEach ( ( ) => { log = [ ] ; } ) ; it ( 'should wait for promise to resolve' , ( ) => { return new Promise ( ( res , _ ) => { setTimeout ( ( ) => { log . push ( 'resolved' ) ; res ( ) ; } , 100 ) ; } ) ; } ) ; afterEach ( ( ) => { expect ( log ) . toEqual ( [ 'resolved' ] ) ; } ) ; } ) ; } ) ( ) ;