@@ -85,27 +85,81 @@ describe('Zone.patch', function () {
8585
8686 it ( 'should work' , function ( done ) {
8787
88- runs ( function ( ) {
89- flag = false ;
90- hasParent = false ;
88+ runs ( function ( ) {
89+ flag = false ;
90+ hasParent = false ;
91+
92+ window . requestAnimationFrame ( function ( ) {
93+ hasParent = ! ! window . zone . parent ;
94+ flag = true ;
95+ } ) ;
96+ } ) ;
97+
98+ waitsFor ( function ( ) {
99+ return flag ;
100+ } , "requestAnimationFrame to run" , 1 ) ;
91101
92- window . requestAnimationFrame ( function ( ) {
93- hasParent = ! ! window . zone . parent ;
94- flag = true ;
102+ runs ( function ( ) {
103+ expect ( hasParent ) . toBe ( true ) ;
95104 } ) ;
105+
96106 } ) ;
107+ } ) ;
97108
98- waitsFor ( function ( ) {
99- return flag ;
100- } , "requestAnimationFrame to run" , 1 ) ;
109+ describe ( 'Promise' , function ( ) {
110+ var flag , hasParent ;
101111
102- runs ( function ( ) {
103- expect ( hasParent ) . toBe ( true ) ;
112+ beforeEach ( function ( ) {
113+ flag = false ;
114+ hasParent = false ;
104115 } ) ;
105116
117+ it ( 'should work with .then' , function ( ) {
118+ if ( ! window . Promise ) {
119+ return ;
120+ }
121+
122+ runs ( function ( ) {
123+ new Promise ( function ( resolve ) {
124+ requestAnimationFrame ( resolve ) ;
125+ } ) . then ( function ( ) {
126+ hasParent = ! ! window . zone . parent ;
127+ flag = true ;
128+ } ) ;
129+ } ) ;
130+
131+ waitsFor ( function ( ) {
132+ return flag ;
133+ } , "requestAnimationFrame to run" , 1 ) ;
134+
135+ runs ( function ( ) {
136+ expect ( hasParent ) . toBe ( true ) ;
137+ } ) ;
106138 } ) ;
107- } ) ;
108139
140+ it ( 'should work with .catch' , function ( ) {
141+ if ( ! window . Promise ) {
142+ return ;
143+ }
144+
145+ runs ( function ( ) {
146+ new Promise ( function ( resolve , reject ) {
147+ requestAnimationFrame ( reject ) ;
148+ } ) . catch ( function ( ) {
149+ hasParent = ! ! window . zone . parent ;
150+ flag = true ;
151+ } ) ;
152+ } ) ;
153+
154+ waitsFor ( function ( ) {
155+ return flag ;
156+ } , "requestAnimationFrame to run" , 1 ) ;
157+
158+ runs ( function ( ) {
159+ expect ( hasParent ) . toBe ( true ) ;
160+ } ) ;
161+ } ) ;
162+ } )
109163
110164 describe ( 'element' , function ( ) {
111165
0 commit comments