OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 @TestOn('vm') |
4 library web_components.test.build.html_import_annotation_recorder_test; | 5 library web_components.test.build.html_import_annotation_recorder_test; |
5 | 6 |
6 import 'package:code_transformers/tests.dart' hide testPhases; | 7 import 'package:transformer_test/utils.dart' hide testPhases; |
7 import 'package:web_components/build/html_import_annotation_recorder.dart'; | 8 import 'package:web_components/build/html_import_annotation_recorder.dart'; |
8 import 'package:initialize/transformer.dart'; | 9 import 'package:initialize/transformer.dart'; |
9 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:test/test.dart'; |
10 import 'package:unittest/unittest.dart'; | |
11 import 'common.dart'; | 11 import 'common.dart'; |
12 | 12 |
13 testPhases(String name, Map<String, String> inputs, | 13 testPhases(String name, Map<String, String> inputs, |
14 Map<String, String> expected, List<String> expectedPaths) { | 14 Map<String, String> expected, List<String> expectedPaths) { |
15 var plugin = new HtmlImportAnnotationRecorder(); | 15 var plugin = new HtmlImportAnnotationRecorder(); |
16 var transformer = | 16 var transformer = |
17 new InitializeTransformer(['web/index.dart'], plugins: [plugin]); | 17 new InitializeTransformer(['web/index.dart'], plugins: [plugin]); |
18 | 18 |
19 test(name, () { | 19 test(name, () { |
20 // Run the transformer and test the output. | 20 // Run the transformer and test the output. |
21 return applyTransformers([[transformer]], | 21 return applyTransformers([ |
| 22 [transformer] |
| 23 ], |
22 inputs: inputs, | 24 inputs: inputs, |
23 results: expected, | 25 results: expected, |
24 formatter: StringFormatter.noNewlinesOrSurroundingWhitespace).then((_) { | 26 formatter: StringFormatter.noNewlinesOrSurroundingWhitespace).then((_) { |
25 // Check that we recorded the right html imports. | 27 // Check that we recorded the right html imports. |
26 expect(plugin.importPaths, expectedPaths); | 28 expect(plugin.importPaths, expectedPaths); |
27 }); | 29 }); |
28 }); | 30 }); |
29 } | 31 } |
30 | 32 |
31 main() { | 33 main() { |
32 useCompactVMConfiguration(); | |
33 | |
34 testPhases('basic', { | 34 testPhases('basic', { |
35 'a|web/index.dart': ''' | 35 'a|web/index.dart': ''' |
36 @HtmlImport('index.html') | 36 @HtmlImport('index.html') |
37 library index; | 37 library index; |
38 | 38 |
39 import 'package:web_components/html_import_annotation.dart'; | 39 import 'package:web_components/html_import_annotation.dart'; |
40 import 'foo.dart'; | 40 import 'foo.dart'; |
41 ''', | 41 ''', |
42 'a|web/foo.dart': ''' | 42 'a|web/foo.dart': ''' |
43 @HtmlImport(fooHtml) | 43 @HtmlImport(fooHtml) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return i0.main(); | 96 return i0.main(); |
97 } | 97 } |
98 ''' | 98 ''' |
99 }, [ | 99 }, [ |
100 'packages/bar/src/zap.html', | 100 'packages/bar/src/zap.html', |
101 'packages/bar/bar.html', | 101 'packages/bar/bar.html', |
102 'foo.html', | 102 'foo.html', |
103 'index.html', | 103 'index.html', |
104 ]); | 104 ]); |
105 } | 105 } |
OLD | NEW |