2015-04-13 19:54:09 -04:00
|
|
|
library angular2.test.transform.template_compiler.all_tests;
|
2015-03-13 16:55:49 -04:00
|
|
|
|
2015-05-14 16:14:45 -04:00
|
|
|
import 'dart:async';
|
2015-03-13 16:55:49 -04:00
|
|
|
import 'package:barback/barback.dart';
|
2015-03-25 18:54:12 -04:00
|
|
|
import 'package:angular2/src/dom/html_adapter.dart';
|
2015-03-13 16:55:49 -04:00
|
|
|
import 'package:angular2/src/transform/common/asset_reader.dart';
|
2015-04-16 11:54:44 -04:00
|
|
|
import 'package:angular2/src/transform/common/logging.dart';
|
2015-03-13 16:55:49 -04:00
|
|
|
import 'package:angular2/src/transform/template_compiler/generator.dart';
|
|
|
|
import 'package:dart_style/dart_style.dart';
|
2015-03-20 18:25:29 -04:00
|
|
|
import 'package:guinness/guinness.dart';
|
2015-03-13 16:55:49 -04:00
|
|
|
|
|
|
|
import '../common/read_file.dart';
|
|
|
|
|
|
|
|
var formatter = new DartFormatter();
|
|
|
|
|
|
|
|
void allTests() {
|
|
|
|
Html5LibDomAdapter.makeCurrent();
|
|
|
|
AssetReader reader = new TestAssetReader();
|
|
|
|
|
2015-04-16 11:54:44 -04:00
|
|
|
beforeEach(() => setLogger(new PrintLogger()));
|
|
|
|
|
2015-05-14 16:14:45 -04:00
|
|
|
describe('registrations', () {
|
|
|
|
Future<String> process(AssetId assetId) =>
|
|
|
|
processTemplates(reader, assetId, generateChangeDetectors: false);
|
|
|
|
|
|
|
|
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 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 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);
|
|
|
|
});
|
|
|
|
|
|
|
|
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 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 `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');
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
output = await process(new AssetId('a', inputPath));
|
|
|
|
_formatThenExpectEquals(output, expected);
|
|
|
|
});
|
2015-06-05 14:10:54 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2015-05-05 13:31:21 -04:00
|
|
|
});
|
2015-03-19 12:16:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _formatThenExpectEquals(String actual, String expected) {
|
|
|
|
expect(formatter.format(actual)).toEqual(formatter.format(expected));
|
2015-03-13 16:55:49 -04:00
|
|
|
}
|