blob: 0856a6614a04bc0d3be73fee69ff5bb5ab935e15 [file] [log] [blame]
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library web_components.test.build.html_import_annotation_inliner_test;
import 'package:code_transformers/tests.dart';
import 'package:web_components/build/html_import_annotation_inliner.dart';
import 'package:unittest/compact_vm_config.dart';
main() {
useCompactVMConfiguration();
var transformer = new HtmlImportAnnotationInliner(
'web/index.bootstrap.dart', 'web/index.html');
testPhases('basic', [[transformer]], {
'foo|web/index.html': '''
<html>
<head></head>
<body>
<script type="application/dart" src="index.bootstrap.dart"></script>
</body>
</html>
''',
'foo|web/index.bootstrap.dart': '''
import 'package:initialize/src/static_loader.dart';
import 'package:initialize/src/initializer.dart';
import 'index.dart' as i0;
import 'package:web_components/html_import_annotation.dart' as i1;
import 'package:baz/baz.dart' as i2;
main() {
initializers.addAll([
new InitEntry(i2.initMethod, i0.baz),
new InitEntry(const i1.HtmlImport('foo.html'), const LibraryIdentifier(#foo, null, 'web/foo.dart')),
new InitEntry(const i1.HtmlImport('foo.html'), const LibraryIdentifier(#foo, null, 'web/foo/foo.dart')),
new InitEntry(const i1.HtmlImport('../foo.html'), const LibraryIdentifier(#foo, null, 'web/foo/foo.dart')),
new InitEntry(const i1.HtmlImport('package:foo/foo.html'), const LibraryIdentifier(#foo, null, 'lib/foo.dart')),
new InitEntry(const i1.HtmlImport('package:foo/foo/foo.html'), const LibraryIdentifier(#foo, null, 'lib/foo/foo.dart')),
new InitEntry(const i1.HtmlImport('bar.html'), const LibraryIdentifier(#bar, 'bar', 'lib/bar.dart')),
new InitEntry(const i1.HtmlImport('bar.html'), const LibraryIdentifier(#bar.Bar, 'bar', 'lib/bar/bar.dart')),
new InitEntry(const i1.HtmlImport('package:bar/bar.html'), const LibraryIdentifier(#bar, 'bar', 'lib/bar.dart')),
new InitEntry(const i1.HtmlImport('package:bar/bar/bar.html'), const LibraryIdentifier(#bar.Bar, 'bar', 'lib/bar/bar.dart')),
]);
i0.main();
}
''',
}, {
'foo|web/index.html': '''
<html>
<head>
<link rel="import" href="foo.html">
<link rel="import" href="foo/foo.html">
<link rel="import" href="packages/foo/foo.html">
<link rel="import" href="packages/foo/foo/foo.html">
<link rel="import" href="packages/bar/bar.html">
<link rel="import" href="packages/bar/bar/bar.html">
</head>
<body>
<script type="application/dart" src="index.bootstrap.dart"></script>
</body>
</html>''',
'foo|web/index.bootstrap.dart': '''
import 'package:initialize/src/static_loader.dart';
import 'package:initialize/src/initializer.dart';
import 'index.dart' as i0;
import 'package:web_components/html_import_annotation.dart' as i1;
import 'package:baz/baz.dart' as i2;
main() {
initializers.addAll([
new InitEntry(i2.initMethod, i0.baz),
]);
i0.main();
}
'''
}, [], StringFormatter.noNewlinesOrSurroundingWhitespace);
}