| 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('browser') |
| 4 @HtmlImport(importPath) | 5 @HtmlImport(importPath) |
| 5 // This one will throw a build time warning, but should still work dynamically. | |
| 6 @HtmlImport('bad_import.html') | |
| 7 library web_components.test.html_import_annotation; | 6 library web_components.test.html_import_annotation; |
| 8 | 7 |
| 9 import 'dart:html'; | 8 import 'dart:html'; |
| 10 import 'package:unittest/html_config.dart'; | 9 import 'package:test/test.dart'; |
| 11 import 'package:unittest/unittest.dart'; | |
| 12 import 'package:web_components/web_components.dart'; | 10 import 'package:web_components/web_components.dart'; |
| 13 import 'foo/bar.dart'; | 11 import 'foo/bar.dart' as foo_bar; |
| 14 | 12 |
| 15 const String importPath = 'my_import.html'; | 13 const String importPath = 'my_import.html'; |
| 16 | 14 |
| 17 main() { | 15 /// Uses [foo_bar]. |
| 18 useHtmlConfiguration(); | 16 main() async { |
| 17 await initWebComponents(); |
| 19 | 18 |
| 20 test('adds import to head', () { | 19 test('adds import to head', () { |
| 21 return initWebComponents().then((_) { | 20 var my_import = document.head.querySelector('link[href="$importPath"]'); |
| 22 var my_import = document.head.querySelector('link[href="$importPath"]'); | 21 expect(my_import, isNotNull); |
| 23 expect(my_import, isNotNull); | 22 expect(my_import.import.body.text, 'Hello world!\n'); |
| 24 expect(my_import.import.body.text, 'Hello world!\n'); | |
| 25 | 23 |
| 26 var bar = document.head.querySelector('link[href="foo/bar.html"]'); | 24 var bar = document.head.querySelector('link[href="foo/bar.html"]'); |
| 27 expect(bar, isNotNull); | 25 expect(bar, isNotNull); |
| 28 expect(bar.import.body.text, 'bar\n'); | 26 expect(bar.import.body.text, 'bar\n'); |
| 29 | |
| 30 var bad = document.head.querySelector('link[href="bad_import.html"]'); | |
| 31 expect(bad.import, isNull); | |
| 32 }); | |
| 33 }); | 27 }); |
| 34 } | 28 } |
| OLD | NEW |