diff --git a/modules/angular2/test/core/compiler/integration_spec.ts b/modules/angular2/test/core/compiler/integration_spec.ts index e019d97468..242c07f64e 100644 --- a/modules/angular2/test/core/compiler/integration_spec.ts +++ b/modules/angular2/test/core/compiler/integration_spec.ts @@ -1248,11 +1248,12 @@ export function main() { if (!IS_DARTIUM) { describe('Missing property bindings', () => { it('should throw on bindings to unknown properties', - inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { + inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, + async) => { tcb = tcb.overrideView(MyComp, new viewAnn.View({template: '
'})) - + PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => { expect(e.message).toEqual( `Can't bind to 'unknown' since it isn't a know property of the 'div' element and there are no matching directives with a corresponding property`); @@ -1260,9 +1261,10 @@ export function main() { return null; }); })); - + it('should not throw for property binding to a non-existing property when there is a matching directive property', - inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { + inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, + async) => { tcb.overrideView( MyComp, new viewAnn.View( @@ -1270,7 +1272,7 @@ export function main() { .createAsync(MyComp) .then((val) => { async.done(); }); })); - }); + }); } // Disabled until a solution is found, refs: diff --git a/modules/angular2/test/render/dom/view/proto_view_builder_spec.ts b/modules/angular2/test/render/dom/view/proto_view_builder_spec.ts index a627d64a25..ef8d00f854 100644 --- a/modules/angular2/test/render/dom/view/proto_view_builder_spec.ts +++ b/modules/angular2/test/render/dom/view/proto_view_builder_spec.ts @@ -24,27 +24,27 @@ export function main() { if (!IS_DARTIUM) { describe('verification of properties', () => { - + it('should throw for unknown properties', () => { builder.bindElement(el('
')).bindProperty('unknownProperty', emptyExpr()); expect(() => builder.build()) .toThrowError( `Can't bind to 'unknownProperty' since it isn't a know property of the 'div' element and there are no matching directives with a corresponding property`); }); - + it('should allow unknown properties if a directive uses it', () => { var binder = builder.bindElement(el('
')); binder.bindDirective(0).bindProperty('someDirProperty', emptyExpr(), 'directiveProperty'); binder.bindProperty('directiveProperty', emptyExpr()); expect(() => builder.build()).not.toThrow(); }); - + it('should allow unknown properties on custom elements', () => { var binder = builder.bindElement(el('')); binder.bindProperty('unknownProperty', emptyExpr()); expect(() => builder.build()).not.toThrow(); }); - + it('should throw for unknown properties on custom elements if there is an ng component', () => { var binder = builder.bindElement(el('')); binder.bindProperty('unknownProperty', emptyExpr()); @@ -53,8 +53,20 @@ export function main() { .toThrowError( `Can't bind to 'unknownProperty' since it isn't a know property of the 'some-custom' element and there are no matching directives with a corresponding property`); }); - - }); + + }); + } else { + describe('verification of properties', () => { + + // TODO(tbosch): This is just a temporary test that makes sure that the dart server and + // dart browser is in sync. Change this to "not contains notifyBinding" + // when https://github.com/angular/angular/issues/3019 is solved. + it('should throw for unknown properties', () => { + builder.bindElement(el('
')).bindProperty('unknownProperty', emptyExpr()); + expect(() => builder.build()).not.toThrow(); + }); + + }); } describe('property normalization', () => { diff --git a/modules/angular2/test/transform/template_compiler/all_tests.dart b/modules/angular2/test/transform/template_compiler/all_tests.dart index af3d3e155a..138410b835 100644 --- a/modules/angular2/test/transform/template_compiler/all_tests.dart +++ b/modules/angular2/test/transform/template_compiler/all_tests.dart @@ -12,109 +12,126 @@ import 'package:guinness/guinness.dart'; import '../common/read_file.dart'; var formatter = new DartFormatter(); +AssetReader reader = new TestAssetReader(); main() => allTests(); void allTests() { Html5LibDomAdapter.makeCurrent(); - AssetReader reader = new TestAssetReader(); - beforeEach(() => setLogger(new PrintLogger())); describe('registrations', () { - Future process(AssetId assetId) => - processTemplates(reader, assetId, generateChangeDetectors: false); + noChangeDetectorTests(); + changeDetectorTests(); + }); +} - it('should parse simple expressions in inline templates.', () async { - var inputPath = - 'template_compiler/inline_expression_files/hello.ng_deps.dart'; - var expected = readFile( - 'template_compiler/inline_expression_files/expected/hello.ng_deps.dart'); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); +void changeDetectorTests() { + Future process(AssetId assetId) => processTemplates(reader, assetId); - it('should parse simple methods in inline templates.', () async { - var inputPath = - 'template_compiler/inline_method_files/hello.ng_deps.dart'; - var expected = readFile( - 'template_compiler/inline_method_files/expected/hello.ng_deps.dart'); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); + // TODO(tbosch): This is just a temporary test that makes sure that the dart server and + // dart browser is in sync. Change this to "not contains notifyBinding" + // when https://github.com/angular/angular/issues/3019 is solved. + it('shouldn always notifyBinding for template variables', () async { + var inputPath = 'template_compiler/ng_for_files/hello.ng_deps.dart'; + var output = await(process(new AssetId('a', inputPath))); + expect(output).toContain('notifyOnBinding'); + }); +} - it('should parse simple expressions in linked templates.', () async { - var inputPath = - 'template_compiler/url_expression_files/hello.ng_deps.dart'; - var expected = readFile( - 'template_compiler/url_expression_files/expected/hello.ng_deps.dart'); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); +void noChangeDetectorTests() { + Future process(AssetId assetId) => + processTemplates(reader, assetId, generateChangeDetectors: false); - it('should parse simple methods in linked templates.', () async { - var inputPath = 'template_compiler/url_method_files/hello.ng_deps.dart'; - var expected = readFile( - 'template_compiler/url_method_files/expected/hello.ng_deps.dart'); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); + it('should parse simple expressions in inline templates.', () async { + var inputPath = + 'template_compiler/inline_expression_files/hello.ng_deps.dart'; + var expected = readFile( + 'template_compiler/inline_expression_files/expected/hello.ng_deps.dart'); + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + }); - it('should not generated duplicate getters/setters', () async { - var inputPath = 'template_compiler/duplicate_files/hello.ng_deps.dart'; - var expected = readFile( - 'template_compiler/duplicate_files/expected/hello.ng_deps.dart'); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); + it('should parse simple methods in inline templates.', () async { + var inputPath = + 'template_compiler/inline_method_files/hello.ng_deps.dart'; + var expected = readFile( + 'template_compiler/inline_method_files/expected/hello.ng_deps.dart'); + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + }); - it('should parse `View` directives with a single dependency.', () async { - var inputPath = - 'template_compiler/one_directive_files/hello.ng_deps.dart'; - var expected = readFile( - 'template_compiler/one_directive_files/expected/hello.ng_deps.dart'); + it('should parse simple expressions in linked templates.', () async { + var inputPath = + 'template_compiler/url_expression_files/hello.ng_deps.dart'; + var expected = readFile( + 'template_compiler/url_expression_files/expected/hello.ng_deps.dart'); + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + }); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); + it('should parse simple methods in linked templates.', () async { + var inputPath = 'template_compiler/url_method_files/hello.ng_deps.dart'; + var expected = readFile( + 'template_compiler/url_method_files/expected/hello.ng_deps.dart'); + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + }); - it('should parse `View` directives with a single prefixed dependency.', - () async { - var inputPath = 'template_compiler/with_prefix_files/hello.ng_deps.dart'; - var expected = readFile( - 'template_compiler/with_prefix_files/expected/hello.ng_deps.dart'); + it('should not generated duplicate getters/setters', () async { + var inputPath = 'template_compiler/duplicate_files/hello.ng_deps.dart'; + var expected = readFile( + 'template_compiler/duplicate_files/expected/hello.ng_deps.dart'); + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + }); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); + it('should parse `View` directives with a single dependency.', () async { + var inputPath = + 'template_compiler/one_directive_files/hello.ng_deps.dart'; + var expected = readFile( + 'template_compiler/one_directive_files/expected/hello.ng_deps.dart'); - inputPath = 'template_compiler/with_prefix_files/goodbye.ng_deps.dart'; - expected = readFile( - 'template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart'); + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + }); - output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); + it('should parse `View` directives with a single prefixed dependency.', + () async { + var inputPath = 'template_compiler/with_prefix_files/hello.ng_deps.dart'; + var expected = readFile( + 'template_compiler/with_prefix_files/expected/hello.ng_deps.dart'); - it('should parse angular directives with a prefix', () async { - var inputPath = - 'template_compiler/with_prefix_files/ng2_prefix.ng_deps.dart'; - var expected = readFile( - 'template_compiler/with_prefix_files/expected/ng2_prefix.ng_deps.dart'); + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); + inputPath = 'template_compiler/with_prefix_files/goodbye.ng_deps.dart'; + expected = readFile( + 'template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart'); - it('should create the same output for multiple calls.', () async { - var inputPath = - 'template_compiler/inline_expression_files/hello.ng_deps.dart'; - var expected = readFile( - 'template_compiler/inline_expression_files/expected/hello.ng_deps.dart'); - var output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - output = await process(new AssetId('a', inputPath)); - _formatThenExpectEquals(output, expected); - }); + output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + }); + + it('should parse angular directives with a prefix', () async { + var inputPath = + 'template_compiler/with_prefix_files/ng2_prefix.ng_deps.dart'; + var expected = readFile( + 'template_compiler/with_prefix_files/expected/ng2_prefix.ng_deps.dart'); + + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + }); + + it('should create the same output for multiple calls.', () async { + var inputPath = + 'template_compiler/inline_expression_files/hello.ng_deps.dart'; + var expected = readFile( + 'template_compiler/inline_expression_files/expected/hello.ng_deps.dart'); + var output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); + output = await process(new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); }); } diff --git a/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_deps.dart new file mode 100644 index 0000000000..ff7e8990d0 --- /dev/null +++ b/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_deps.dart @@ -0,0 +1,22 @@ +library test.src.transform.template_compiler.ng_for_files.hello.ng_deps.dart; + +import 'hello.dart'; +import 'package:angular2/angular2.dart' + show bootstrap, Component, Directive, View, NgElement; + +var _visited = false; +void initReflector(reflector) { + if (_visited) return; + _visited = true; + reflector + ..registerType(HelloCmp, { + 'factory': () => new HelloCmp(), + 'parameters': const [const []], + 'annotations': const [ + const Component(selector: 'hello-app'), + const View( + template: '
  • test
  • ', + directives: const [NgFor]) + ] + }); +} diff --git a/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_meta.json b/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_meta.json new file mode 100644 index 0000000000..eab28548e9 --- /dev/null +++ b/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_meta.json @@ -0,0 +1,13 @@ +{ + "HelloCmp": + { + "id":"HelloCmp", + "selector":"hello-app", + "compileChildren":true, + "host":{}, + "properties":[], + "readAttributes":[], + "type":1, + "version":1 + } +} \ No newline at end of file