@@ -3,6 +3,7 @@ library scope2_spec;
3
3
import '../_specs.dart' ;
4
4
import 'package:angular/change_detection/change_detection.dart' hide ExceptionHandler;
5
5
import 'package:angular/change_detection/dirty_checking_change_detector.dart' ;
6
+ import 'dart:async' ;
6
7
import 'dart:math' ;
7
8
8
9
main () => describe ('scope' , () {
@@ -1285,6 +1286,40 @@ main() => describe('scope', () {
1285
1286
});
1286
1287
});
1287
1288
});
1289
+
1290
+ describe ('exceptionHander' , () {
1291
+ it ('should call ExceptionHandler on zone errors' , () {
1292
+ module ((Module module) {
1293
+ module.type (ExceptionHandler , implementedBy: LoggingExceptionHandler );
1294
+ });
1295
+ async ((inject ((RootScope rootScope, NgZone zone, ExceptionHandler e) {
1296
+ zone.run (() {
1297
+ scheduleMicrotask (() => throw 'my error' );
1298
+ });
1299
+ var errors = (e as LoggingExceptionHandler ).errors;
1300
+ expect (errors.length).toEqual (1 );
1301
+ expect (errors.first.error).toEqual ('my error' );
1302
+ })));
1303
+ });
1304
+
1305
+ it ('should call ExceptionHandler on digest errors' , () {
1306
+ module ((Module module) {
1307
+ module.type (ExceptionHandler , implementedBy: LoggingExceptionHandler );
1308
+ });
1309
+ async ((inject ((RootScope rootScope, NgZone zone, ExceptionHandler e) {
1310
+ rootScope.context['badOne' ] = () => new Map ();
1311
+ rootScope.watch ('badOne()' , (_, __) => null );
1312
+
1313
+ try {
1314
+ zone.run (() => null );
1315
+ } catch (_) {}
1316
+
1317
+ var errors = (e as LoggingExceptionHandler ).errors;
1318
+ expect (errors.length).toEqual (1 );
1319
+ expect (errors.first.error, startsWith ('Model did not stabilize' ));
1320
+ })));
1321
+ });
1322
+ });
1288
1323
});
1289
1324
1290
1325
@NgFilter (name: 'multiply' )
0 commit comments