@@ -267,6 +267,59 @@ main() => describe('scope', () {
267
267
child.broadcast ('abc' );
268
268
expect (log).toEqual ('' );
269
269
}));
270
+
271
+ it ('should not trigger assertions on scope fork' , inject ((RootScope root) {
272
+ var d1 = root.createChild ({});
273
+ var d2 = root.createChild ({});
274
+ var d3 = d2.createChild ({});
275
+ expect (root.apply).not.toThrow ();
276
+ d1.on (ScopeEvent .DESTROY ).listen ((_) => null );
277
+ expect (root.apply).not.toThrow ();
278
+ d3.on (ScopeEvent .DESTROY ).listen ((_) => null );
279
+ expect (root.apply).not.toThrow ();
280
+ d2.on (ScopeEvent .DESTROY ).listen ((_) => null );
281
+ expect (root.apply).not.toThrow ();
282
+ }));
283
+
284
+ it ('should not too eagerly create own streams' , inject ((RootScope root) {
285
+ var a = root.createChild ({});
286
+ var a2 = root.createChild ({});
287
+ var b = a.createChild ({});
288
+ var c = b.createChild ({});
289
+ var d = c.createChild ({});
290
+ var e = d.createChild ({});
291
+
292
+ getStreamState () => [root.hasOwnStreams, a.hasOwnStreams, a2.hasOwnStreams,
293
+ b.hasOwnStreams, c.hasOwnStreams, d.hasOwnStreams,
294
+ e.hasOwnStreams];
295
+
296
+ expect (getStreamState ()).toEqual ([false , false , false , false , false , false , false ]);
297
+ expect (root.apply).not.toThrow ();
298
+
299
+ e.on (ScopeEvent .DESTROY ).listen ((_) => null );
300
+ expect (getStreamState ()).toEqual ([false , false , false , false , false , false , true ]);
301
+ expect (root.apply).not.toThrow ();
302
+
303
+ d.on (ScopeEvent .DESTROY ).listen ((_) => null );
304
+ expect (getStreamState ()).toEqual ([false , false , false , false , false , true , true ]);
305
+ expect (root.apply).not.toThrow ();
306
+
307
+ b.on (ScopeEvent .DESTROY ).listen ((_) => null );
308
+ expect (getStreamState ()).toEqual ([false , false , false , true , false , true , true ]);
309
+ expect (root.apply).not.toThrow ();
310
+
311
+ c.on (ScopeEvent .DESTROY ).listen ((_) => null );
312
+ expect (getStreamState ()).toEqual ([false , false , false , true , true , true , true ]);
313
+ expect (root.apply).not.toThrow ();
314
+
315
+ a.on (ScopeEvent .DESTROY ).listen ((_) => null );
316
+ expect (getStreamState ()).toEqual ([false , true , false , true , true , true , true ]);
317
+ expect (root.apply).not.toThrow ();
318
+
319
+ a2.on (ScopeEvent .DESTROY ).listen ((_) => null );
320
+ expect (getStreamState ()).toEqual ([true , true , true , true , true , true , true ]);
321
+ expect (root.apply).not.toThrow ();
322
+ }));
270
323
});
271
324
272
325
@@ -1047,7 +1100,7 @@ main() => describe('scope', () {
1047
1100
}));
1048
1101
});
1049
1102
1050
-
1103
+
1051
1104
describe ('runAsync' , () {
1052
1105
it (r'should run callback before watch' , inject ((RootScope rootScope) {
1053
1106
var log = '' ;
0 commit comments