chore(transformer): add a test that generated change detectors dont call notifyOnBinding for template variables
This commit is contained in:

committed by
Tobias Bosch

parent
b3a763a718
commit
4bdc91892a
@ -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<String> 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<String> 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<String> 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);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user