@@ -31,23 +31,29 @@ describe('setTimeout', function () {
3131 } ) ;
3232
3333 it ( 'should allow canceling of fns registered with setTimeout' , function ( done ) {
34- var spy = jasmine . createSpy ( 'spy' ) ;
35- var cancelId = setTimeout ( spy , 0 ) ;
36- clearTimeout ( cancelId ) ;
37- setTimeout ( function ( ) {
38- expect ( spy ) . not . toHaveBeenCalled ( ) ;
39- done ( ) ;
34+ var testZone = Zone . current . fork ( Zone [ 'wtfZoneSpec' ] ) . fork ( { name : 'TestZone' } ) ;
35+ testZone . run ( ( ) => {
36+ var spy = jasmine . createSpy ( 'spy' ) ;
37+ var cancelId = setTimeout ( spy , 0 ) ;
38+ clearTimeout ( cancelId ) ;
39+ setTimeout ( function ( ) {
40+ expect ( spy ) . not . toHaveBeenCalled ( ) ;
41+ done ( ) ;
42+ } ) ;
4043 } ) ;
4144 } ) ;
4245
43- it ( 'should allow double cancelation of fns registered with setTimeout' , function ( done ) {
44- var spy = jasmine . createSpy ( 'spy' ) ;
45- var cancelId = setTimeout ( spy , 0 ) ;
46- setTimeout ( function ( ) {
47- expect ( spy ) . toHaveBeenCalled ( ) ;
46+ it ( 'should allow cancelation of fns registered with setTimeout after invocation ' , function ( done ) {
47+ var testZone = Zone . current . fork ( Zone [ 'wtfZoneSpec' ] ) . fork ( { name : 'TestZone' } ) ;
48+ testZone . run ( ( ) => {
49+ var spy = jasmine . createSpy ( 'spy' ) ;
50+ var cancelId = setTimeout ( spy , 0 ) ;
4851 setTimeout ( function ( ) {
49- clearTimeout ( cancelId ) ;
50- done ( ) ;
52+ expect ( spy ) . toHaveBeenCalled ( ) ;
53+ setTimeout ( function ( ) {
54+ clearTimeout ( cancelId ) ;
55+ done ( ) ;
56+ } ) ;
5157 } ) ;
5258 } ) ;
5359 } ) ;
@@ -59,6 +65,16 @@ describe('setTimeout', function () {
5965 } , 0 ) ;
6066 } ) ;
6167
68+ it ( 'should allow cancelation of fns registered with setTimeout during invocation' , function ( done ) {
69+ var testZone = Zone . current . fork ( Zone [ 'wtfZoneSpec' ] ) . fork ( { name : 'TestZone' } ) ;
70+ testZone . run ( ( ) => {
71+ var cancelId = setTimeout ( function ( ) {
72+ clearTimeout ( cancelId ) ;
73+ done ( ) ;
74+ } , 0 ) ;
75+ } ) ;
76+ } ) ;
77+
6278 it ( 'should pass invalid values through' , function ( ) {
6379 clearTimeout ( null ) ;
6480 clearTimeout ( < any > { } ) ;
0 commit comments