| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library todomvc.test.listorder_test; |
| 6 |
| 7 import 'dart:html'; |
| 8 import 'package:polymer/polymer.dart'; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 import 'package:unittest/html_config.dart'; |
| 11 import '../web/model.dart'; |
| 12 |
| 13 /** |
| 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 |
| 16 * nodes to be hidden and readded to the page. |
| 17 */ |
| 18 main() { |
| 19 useHtmlConfiguration(); |
| 20 |
| 21 final root = query('todo-app').shadowRoot; |
| 22 |
| 23 test('programmatically add items to model', () { |
| 24 appModel.todos.addAll([ |
| 25 new Todo('one (unchecked)'), |
| 26 new Todo('two (checked)')..done = true, |
| 27 new Todo('three (unchecked)') |
| 28 ]); |
| 29 performMicrotaskCheckpoint(); |
| 30 expect(root.queryAll('#todo-list li[is=todo-row]').length, 3); |
| 31 |
| 32 // TODO(jmesserly): HTML Imports breaks relative hash links when the |
| 33 // component is at a different path from the main HTML document. For now we |
| 34 // fix it programmatically. |
| 35 for (var a in root.queryAll('#filters > li > a')) { |
| 36 a.href = '#${Uri.parse(a.href).fragment}'; |
| 37 } |
| 38 }); |
| 39 |
| 40 test('navigate to #/active', () { |
| 41 windowLocation.hash = '#/active'; |
| 42 performMicrotaskCheckpoint(); |
| 43 expect(root.queryAll('#todo-list li[is=todo-row]').length, 2); |
| 44 }); |
| 45 |
| 46 test('navigate to #/completed', () { |
| 47 windowLocation.hash = '#/completed'; |
| 48 performMicrotaskCheckpoint(); |
| 49 expect(root.queryAll('#todo-list li[is=todo-row]').length, 1); |
| 50 }); |
| 51 |
| 52 test('navigate back to #/', () { |
| 53 windowLocation.hash = '#/'; |
| 54 performMicrotaskCheckpoint(); |
| 55 expect(root.queryAll('#todo-list li[is=todo-row]').length, 3); |
| 56 }); |
| 57 } |
| OLD | NEW |