OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 4 |
| 5 import 'dart:async'; |
5 import 'dart:html'; | 6 import 'dart:html'; |
6 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
7 import 'package:unittest/html_config.dart'; | 8 import 'package:unittest/html_config.dart'; |
8 import 'package:polymer/polymer.dart'; | 9 import 'package:polymer/polymer.dart'; |
9 import 'package:template_binding/template_binding.dart'; | 10 import 'package:template_binding/template_binding.dart'; |
10 | 11 |
11 main() { | 12 Future<List<MutationRecord>> onMutation(Node node) { |
12 initPolymer(); | 13 var completer = new Completer(); |
| 14 new MutationObserver((mutations, observer) { |
| 15 observer.disconnect(); |
| 16 completer.complete(mutations); |
| 17 })..observe(node, childList: true, subtree: true); |
| 18 return completer.future; |
| 19 } |
| 20 |
| 21 main() => initPolymer().run(() { |
13 useHtmlConfiguration(); | 22 useHtmlConfiguration(); |
14 templateBind(querySelector("#a")).model = "foo"; | |
15 | 23 |
16 setUp(() => Polymer.onReady); | 24 var ready = Polymer.onReady.then((_) { |
| 25 var a = querySelector("#a"); |
| 26 templateBind(a).model = "foo"; |
| 27 return onMutation(a.parent); |
| 28 }); |
| 29 |
| 30 setUp(() => ready); |
17 | 31 |
18 test('template found with multiple noscript declarations', () { | 32 test('template found with multiple noscript declarations', () { |
19 expect(querySelector('x-a') is PolymerElement, isTrue); | 33 expect(querySelector('x-a') is PolymerElement, isTrue); |
20 expect(querySelector('x-a').shadowRoot.nodes.first.text, 'a'); | 34 expect(querySelector('x-a').shadowRoot.nodes.first.text, 'a'); |
21 | 35 |
22 expect(querySelector('x-c') is PolymerElement, isTrue); | 36 expect(querySelector('x-c') is PolymerElement, isTrue); |
23 expect(querySelector('x-c').shadowRoot.nodes.first.text, 'c'); | 37 expect(querySelector('x-c').shadowRoot.nodes.first.text, 'c'); |
24 | 38 |
25 expect(querySelector('x-b') is PolymerElement, isTrue); | 39 expect(querySelector('x-b') is PolymerElement, isTrue); |
26 expect(querySelector('x-b').shadowRoot.nodes.first.text, 'b'); | 40 expect(querySelector('x-b').shadowRoot.nodes.first.text, 'b'); |
27 | 41 |
28 expect(querySelector('x-d') is PolymerElement, isTrue); | 42 expect(querySelector('x-d') is PolymerElement, isTrue); |
29 expect(querySelector('x-d').shadowRoot.nodes.first.text, 'd'); | 43 expect(querySelector('x-d').shadowRoot.nodes.first.text, 'd'); |
30 }); | 44 }); |
31 } | 45 }); |
OLD | NEW |