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 library todomvc.test.listorder_test; | 5 library todomvc.test.listorder_test; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'package:unittest/html_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
11 import '../web/model.dart'; | 11 import '../web/model.dart'; |
12 | 12 |
13 /** | 13 /** |
14 * This test runs the TodoMVC app, adds a few elements, marks some as done, and | 14 * This test runs the TodoMVC app, adds a few elements, marks some as done, and |
15 * switches from back and forth between "Active" and "All". This will make some | 15 * switches from back and forth between "Active" and "All". This will make some |
16 * nodes to be hidden and readded to the page. | 16 * nodes to be hidden and readded to the page. |
17 */ | 17 */ |
18 @initMethod | 18 @initMethod |
19 _main() { | 19 _main() { |
20 useHtmlConfiguration(); | 20 useHtmlConfiguration(); |
21 | 21 |
22 final root = query('todo-app').shadowRoot; | |
23 | 22 |
24 setUp(() => Polymer.onReady); | 23 ShadowRoot root; |
| 24 |
| 25 setUp(() => Polymer.onReady.then((_) { |
| 26 root = query('todo-app').shadowRoot; |
| 27 })); |
25 | 28 |
26 test('programmatically add items to model', () { | 29 test('programmatically add items to model', () { |
27 appModel.todos.addAll([ | 30 appModel.todos.addAll([ |
28 new Todo('one (unchecked)'), | 31 new Todo('one (unchecked)'), |
29 new Todo('two (checked)')..done = true, | 32 new Todo('two (checked)')..done = true, |
30 new Todo('three (unchecked)') | 33 new Todo('three (unchecked)') |
31 ]); | 34 ]); |
32 performMicrotaskCheckpoint(); | 35 endOfMicrotask(expectAsync0(() { |
33 expect(root.queryAll('#todo-list li[is=todo-row]').length, 3); | 36 expect(root.queryAll('#todo-list li[is=todo-row]').length, 3); |
34 | 37 |
35 // TODO(jmesserly): HTML Imports breaks relative hash links when the | 38 // TODO(jmesserly): HTML Imports breaks relative hash links when the |
36 // component is at a different path from the main HTML document. For now we | 39 // component is at a different path from the main HTML document. For now |
37 // fix it programmatically. | 40 // fix it programmatically. |
38 for (var a in root.queryAll('#filters > li > a')) { | 41 for (var a in root.queryAll('#filters > li > a')) { |
39 a.href = '#${Uri.parse(a.href).fragment}'; | 42 a.href = '#${Uri.parse(a.href).fragment}'; |
40 } | 43 } |
| 44 })); |
41 }); | 45 }); |
42 | 46 |
43 test('navigate to #/active', () { | 47 test('navigate to #/active', () { |
44 windowLocation.hash = '#/active'; | 48 windowLocation.hash = '#/active'; |
45 performMicrotaskCheckpoint(); | 49 endOfMicrotask(expectAsync0(() { |
46 expect(root.queryAll('#todo-list li[is=todo-row]').length, 2); | 50 expect(root.queryAll('#todo-list li[is=todo-row]').length, 2); |
| 51 })); |
47 }); | 52 }); |
48 | 53 |
49 test('navigate to #/completed', () { | 54 test('navigate to #/completed', () { |
50 windowLocation.hash = '#/completed'; | 55 windowLocation.hash = '#/completed'; |
51 performMicrotaskCheckpoint(); | 56 endOfMicrotask(expectAsync0(() { |
52 expect(root.queryAll('#todo-list li[is=todo-row]').length, 1); | 57 expect(root.queryAll('#todo-list li[is=todo-row]').length, 1); |
| 58 })); |
53 }); | 59 }); |
54 | 60 |
55 test('navigate back to #/', () { | 61 test('navigate back to #/', () { |
56 windowLocation.hash = '#/'; | 62 windowLocation.hash = '#/'; |
57 performMicrotaskCheckpoint(); | 63 endOfMicrotask(expectAsync0(() { |
58 expect(root.queryAll('#todo-list li[is=todo-row]').length, 3); | 64 expect(root.queryAll('#todo-list li[is=todo-row]').length, 3); |
| 65 })); |
59 }); | 66 }); |
60 } | 67 } |
OLD | NEW |