diff --git a/modules/angular2/test/core/compiler/integration_dart_spec.dart b/modules/angular2/test/core/compiler/integration_dart_spec.dart index 72d6c3d84d..acf6e908f7 100644 --- a/modules/angular2/test/core/compiler/integration_dart_spec.dart +++ b/modules/angular2/test/core/compiler/integration_dart_spec.dart @@ -74,6 +74,36 @@ main() { }); })); }); + + describe('Property access', () { + it('should distinguish between map and property access', + inject([TestBed, AsyncTestCompleter], (tb, async) { + tb.overrideView(Dummy, new View( + template: '', + directives: [PropertyAccess] + )); + + tb.createView(Dummy).then((view) { + view.detectChanges(); + expect(view.rootNodes).toHaveText('prop:foo-prop;map:foo-map'); + async.done(); + }); + })); + + it('should not fallback on map access if property missing', + inject([TestBed, AsyncTestCompleter], (tb, async) { + tb.overrideView(Dummy, new View( + template: '', + directives: [NoPropertyAccess] + )); + + tb.createView(Dummy).then((view) { + expect(() => view.detectChanges()) + .toThrowError(new RegExp('property not found')); + async.done(); + }); + })); + }); } @Component(selector: 'dummy') @@ -115,3 +145,26 @@ class ThrowingComponent2 { functionThatThrowsNonError(); } } + +@proxy +class PropModel implements Map { + final String foo = 'foo-prop'; + + operator[](_) => 'foo-map'; + + noSuchMethod(_) { + throw 'property not found'; + } +} + +@Component(selector: 'property-access') +@View(template: '''prop:{{model.foo}};map:{{model['foo']}}''') +class PropertyAccess { + final model = new PropModel(); +} + +@Component(selector: 'no-property-access') +@View(template: '''{{model.doesNotExist}}''') +class NoPropertyAccess { + final model = new PropModel(); +}