diff --git a/modules/angular2/test/transform/template_compiler/all_tests.dart b/modules/angular2/test/transform/template_compiler/all_tests.dart index 1d809d08e0..847fb6a3dc 100644 --- a/modules/angular2/test/transform/template_compiler/all_tests.dart +++ b/modules/angular2/test/transform/template_compiler/all_tests.dart @@ -3,11 +3,13 @@ library angular2.test.transform.directive_processor.all_tests; import 'package:barback/barback.dart'; import 'package:angular2/src/dom/html_adapter.dart'; import 'package:angular2/src/transform/common/asset_reader.dart'; +import 'package:angular2/src/transform/common/logging.dart'; import 'package:angular2/src/transform/common/formatter.dart'; import 'package:angular2/src/transform/template_compiler/generator.dart'; import 'package:dart_style/dart_style.dart'; import 'package:guinness/guinness.dart'; +import '../common/logger.dart'; import '../common/read_file.dart'; var formatter = new DartFormatter(); @@ -15,6 +17,7 @@ var formatter = new DartFormatter(); void allTests() { Html5LibDomAdapter.makeCurrent(); AssetReader reader = new TestAssetReader(); + setLogger(new NullLogger()); it('should parse simple expressions in inline templates.', () async { var inputPath = @@ -22,9 +25,7 @@ void allTests() { var expected = readFile( 'template_compiler/inline_expression_files/expected/hello.ng_deps.dart'); var output = await processTemplates(reader, new AssetId('a', inputPath)); - output = formatter.format(output); - expected = formatter.format(expected); - expect(output).toEqual(expected); + _formatThenExpectEquals(output, expected); }); it('should parse simple methods in inline templates.', () async { @@ -32,8 +33,26 @@ void allTests() { var expected = readFile( 'template_compiler/inline_method_files/expected/hello.ng_deps.dart'); var output = await processTemplates(reader, new AssetId('a', inputPath)); - output = formatter.format(output); - expected = formatter.format(expected); - expect(output).toEqual(expected); + _formatThenExpectEquals(output, expected); + }); + + 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 processTemplates(reader, 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 processTemplates(reader, new AssetId('a', inputPath)); + _formatThenExpectEquals(output, expected); }); } + +void _formatThenExpectEquals(String actual, String expected) { + expect(formatter.format(actual)).toEqual(formatter.format(expected)); +} diff --git a/modules/angular2/test/transform/template_compiler/url_expression_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/url_expression_files/expected/hello.ng_deps.dart new file mode 100644 index 0000000000..a99b14c05d --- /dev/null +++ b/modules/angular2/test/transform/template_compiler/url_expression_files/expected/hello.ng_deps.dart @@ -0,0 +1,22 @@ +library examples.src.hello_world.index_common_dart; + +import 'hello.dart'; +import 'package:angular2/angular2.dart' + show bootstrap, Component, Decorator, Template, NgElement; + +bool _visited = false; +void setupReflection(reflector) { + if (_visited) return; + _visited = true; + reflector + ..registerType(HelloCmp, { + 'factory': () => new HelloCmp(), + 'parameters': const [const []], + 'annotations': const [ + const Component(selector: 'hello-app'), + const Template(url: 'template.html') + ] + }) + ..registerGetters({'greeting': (o) => o.greeting}) + ..registerSetters({'greeting': (o, v) => o.greeting = v}); +} diff --git a/modules/angular2/test/transform/template_compiler/url_expression_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/url_expression_files/hello.ng_deps.dart new file mode 100644 index 0000000000..6a78f6328e --- /dev/null +++ b/modules/angular2/test/transform/template_compiler/url_expression_files/hello.ng_deps.dart @@ -0,0 +1,20 @@ +library examples.src.hello_world.index_common_dart; + +import 'hello.dart'; +import 'package:angular2/angular2.dart' + show bootstrap, Component, Decorator, Template, NgElement; + +bool _visited = false; +void setupReflection(reflector) { + if (_visited) return; + _visited = true; + reflector + ..registerType(HelloCmp, { + 'factory': () => new HelloCmp(), + 'parameters': const [const []], + 'annotations': const [ + const Component(selector: 'hello-app'), + const Template(url: 'template.html') + ] + }); +} diff --git a/modules/angular2/test/transform/template_compiler/url_expression_files/template.html b/modules/angular2/test/transform/template_compiler/url_expression_files/template.html new file mode 100644 index 0000000000..d75013393f --- /dev/null +++ b/modules/angular2/test/transform/template_compiler/url_expression_files/template.html @@ -0,0 +1 @@ +{{greeting}} \ No newline at end of file diff --git a/modules/angular2/test/transform/template_compiler/url_method_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/url_method_files/expected/hello.ng_deps.dart new file mode 100644 index 0000000000..f9692eeac1 --- /dev/null +++ b/modules/angular2/test/transform/template_compiler/url_method_files/expected/hello.ng_deps.dart @@ -0,0 +1,22 @@ +library examples.src.hello_world.index_common_dart; + +import 'hello.dart'; +import 'package:angular2/angular2.dart' + show bootstrap, Component, Decorator, Template, NgElement; + +bool _visited = false; +void setupReflection(reflector) { + if (_visited) return; + _visited = true; + reflector + ..registerType(HelloCmp, { + 'factory': () => new HelloCmp(), + 'parameters': const [const []], + 'annotations': const [ + const Component(selector: 'hello-app'), + const Template(url: 'template.html') + ] + }) + ..registerMethods( + {'action': (o, List args) => Function.apply(o.action, args)}); +} diff --git a/modules/angular2/test/transform/template_compiler/url_method_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/url_method_files/hello.ng_deps.dart new file mode 100644 index 0000000000..6a78f6328e --- /dev/null +++ b/modules/angular2/test/transform/template_compiler/url_method_files/hello.ng_deps.dart @@ -0,0 +1,20 @@ +library examples.src.hello_world.index_common_dart; + +import 'hello.dart'; +import 'package:angular2/angular2.dart' + show bootstrap, Component, Decorator, Template, NgElement; + +bool _visited = false; +void setupReflection(reflector) { + if (_visited) return; + _visited = true; + reflector + ..registerType(HelloCmp, { + 'factory': () => new HelloCmp(), + 'parameters': const [const []], + 'annotations': const [ + const Component(selector: 'hello-app'), + const Template(url: 'template.html') + ] + }); +} diff --git a/modules/angular2/test/transform/template_compiler/url_method_files/template.html b/modules/angular2/test/transform/template_compiler/url_method_files/template.html new file mode 100644 index 0000000000..f985e49978 --- /dev/null +++ b/modules/angular2/test/transform/template_compiler/url_method_files/template.html @@ -0,0 +1 @@ + \ No newline at end of file