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

Commit

Permalink
chore: add missing test for unstable model
Browse files Browse the repository at this point in the history
Closes #633
  • Loading branch information
mhevery committed Apr 9, 2014
1 parent 4231f8c commit 90b576b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/core/scope_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,30 @@ void main() {
beforeEachModule((Module module) {
module.type(ExceptionHandler, implementedBy: LoggingExceptionHandler);
});


it(r'should dispatch exceptions to the exceptionHandler', (ExceptionHandler e) {
LoggingExceptionHandler exceptionHandler = e;
child.on('myEvent').listen((e) { throw 'bubbleException'; });
grandChild.emit(r'myEvent');
expect(log.join('>')).toEqual('2>1>0');
expect(exceptionHandler.errors[0].error).toEqual('bubbleException');
});


it('should throw "model unstable" error when observer is present', (RootScope rootScope, NgZone zone, ExceptionHandler e) {
// Generates a different, equal, list on each evaluation.
rootScope.context['list'] = new UnstableList();

rootScope.watch('list.list', (n, v) => null, canChangeModel: true);
try {
zone.run(() => null);
} catch(_) {}

var errors = (e as LoggingExceptionHandler).errors;
expect(errors.length).toEqual(1);
expect(errors.first.error, startsWith('Model did not stabilize'));
});
});

it(r'should allow stopping event propagation', (RootScope rootScope) {
Expand Down Expand Up @@ -1601,3 +1618,8 @@ class MockScopeStatsEmitter implements ScopeStatsEmitter {
invoked = true;
}
}

class UnstableList {
List get list => new List.generate(3, (i) => i);
}

0 comments on commit 90b576b

Please sign in to comment.