This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,6 +189,40 @@ describe('Zone.patch', function () {
189189 } ) . toThrow ( ) ;
190190 } ) ;
191191
192+ it ( 'should fire onZoneCreeated when a zone is forked' , function ( ) {
193+ var createdSpy = jasmine . createSpy ( ) ;
194+ var counter = 0 ;
195+ var myZone = zone . fork ( {
196+ onZoneCreated : function ( ) {
197+ counter += 1 ;
198+ } ,
199+ onZoneLeave : function ( ) {
200+ counter -= 1 ;
201+ }
202+ } ) ;
203+
204+ myZone . run ( function ( ) {
205+
206+ expect ( counter ) . toBe ( 0 ) ;
207+
208+ setTimeout ( function ( ) {
209+ expect ( counter ) . toBe ( 2 ) ;
210+ } , 0 ) ;
211+ expect ( counter ) . toBe ( 1 ) ;
212+
213+ setTimeout ( function ( ) {
214+ expect ( counter ) . toBe ( 1 ) ;
215+ setTimeout ( function ( ) { } , 0 ) ;
216+ expect ( counter ) . toBe ( 2 ) ;
217+ } , 0 ) ;
218+ expect ( counter ) . toBe ( 2 ) ;
219+
220+ jasmine . Clock . tick ( 1 ) ;
221+
222+ expect ( counter ) . toBe ( 0 ) ;
223+ } ) ;
224+ } ) ;
225+
192226 it ( 'should fire onError if a function run by a zone throws' , function ( ) {
193227 var errorSpy = jasmine . createSpy ( ) ;
194228 var myZone = zone . fork ( {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Zone.prototype = {
1818 constructor : Zone ,
1919
2020 fork : function ( locals ) {
21+ this . onZoneCreated ( ) ;
2122 return new Zone ( this , locals ) ;
2223 } ,
2324
@@ -53,6 +54,7 @@ Zone.prototype = {
5354 } ,
5455
5556 onZoneEnter : function ( ) { } ,
57+ onZoneCreated : function ( ) { } ,
5658 onZoneLeave : function ( ) { }
5759} ;
5860
You can’t perform that action at this time.
0 commit comments