@@ -31,23 +31,29 @@ describe('setTimeout', function () {
31
31
} ) ;
32
32
33
33
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
+ } ) ;
40
43
} ) ;
41
44
} ) ;
42
45
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 ) ;
48
51
setTimeout ( function ( ) {
49
- clearTimeout ( cancelId ) ;
50
- done ( ) ;
52
+ expect ( spy ) . toHaveBeenCalled ( ) ;
53
+ setTimeout ( function ( ) {
54
+ clearTimeout ( cancelId ) ;
55
+ done ( ) ;
56
+ } ) ;
51
57
} ) ;
52
58
} ) ;
53
59
} ) ;
@@ -59,6 +65,16 @@ describe('setTimeout', function () {
59
65
} , 0 ) ;
60
66
} ) ;
61
67
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
+
62
78
it ( 'should pass invalid values through' , function ( ) {
63
79
clearTimeout ( null ) ;
64
80
clearTimeout ( < any > { } ) ;
0 commit comments