Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 90b576b

Browse files
committed
chore: add missing test for unstable model
Closes #633
1 parent 4231f8c commit 90b576b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/core/scope_spec.dart

+22
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,30 @@ void main() {
490490
beforeEachModule((Module module) {
491491
module.type(ExceptionHandler, implementedBy: LoggingExceptionHandler);
492492
});
493+
494+
493495
it(r'should dispatch exceptions to the exceptionHandler', (ExceptionHandler e) {
494496
LoggingExceptionHandler exceptionHandler = e;
495497
child.on('myEvent').listen((e) { throw 'bubbleException'; });
496498
grandChild.emit(r'myEvent');
497499
expect(log.join('>')).toEqual('2>1>0');
498500
expect(exceptionHandler.errors[0].error).toEqual('bubbleException');
499501
});
502+
503+
504+
it('should throw "model unstable" error when observer is present', (RootScope rootScope, NgZone zone, ExceptionHandler e) {
505+
// Generates a different, equal, list on each evaluation.
506+
rootScope.context['list'] = new UnstableList();
507+
508+
rootScope.watch('list.list', (n, v) => null, canChangeModel: true);
509+
try {
510+
zone.run(() => null);
511+
} catch(_) {}
512+
513+
var errors = (e as LoggingExceptionHandler).errors;
514+
expect(errors.length).toEqual(1);
515+
expect(errors.first.error, startsWith('Model did not stabilize'));
516+
});
500517
});
501518

502519
it(r'should allow stopping event propagation', (RootScope rootScope) {
@@ -1601,3 +1618,8 @@ class MockScopeStatsEmitter implements ScopeStatsEmitter {
16011618
invoked = true;
16021619
}
16031620
}
1621+
1622+
class UnstableList {
1623+
List get list => new List.generate(3, (i) => i);
1624+
}
1625+

0 commit comments

Comments
 (0)