| 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.markdone_test; | 5 library todomvc.test.markdone_test; |
| 6 | 6 |
| 7 import 'dart:async'; | |
| 8 import 'dart:html'; | 7 import 'dart:html'; |
| 9 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 11 import 'package:unittest/html_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
| 12 import '../web/model.dart'; | 11 import '../web/model.dart'; |
| 13 | 12 |
| 14 Node findWithText(Node node, String text) { | 13 Node findWithText(Node node, String text) { |
| 15 if (node.text == text) return node; | 14 if (node.text == text) return node; |
| 16 if (node is Element && (node as Element).localName == 'polymer-element') { | 15 if (node is Element && (node as Element).localName == 'polymer-element') { |
| 17 return null; | 16 return null; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 43 return null; | 42 return null; |
| 44 } | 43 } |
| 45 | 44 |
| 46 /** | 45 /** |
| 47 * This test runs the TodoMVC app, adds a few todos, marks some as done | 46 * This test runs the TodoMVC app, adds a few todos, marks some as done |
| 48 * programatically, and clicks on a checkbox to mark others via the UI. | 47 * programatically, and clicks on a checkbox to mark others via the UI. |
| 49 */ | 48 */ |
| 50 main() { | 49 main() { |
| 51 useHtmlConfiguration(); | 50 useHtmlConfiguration(); |
| 52 | 51 |
| 53 setUp(() => new Future.delayed(Duration.ZERO)); | 52 setUp(() => Polymer.onReady); |
| 54 | 53 |
| 55 test('mark done', () { | 54 test('mark done', () { |
| 56 appModel.todos.add(new Todo('one (unchecked)')); | 55 appModel.todos.add(new Todo('one (unchecked)')); |
| 57 appModel.todos.add(new Todo('two (unchecked)')); | 56 appModel.todos.add(new Todo('two (unchecked)')); |
| 58 appModel.todos.add(new Todo('three (checked)')..done = true); | 57 appModel.todos.add(new Todo('three (checked)')..done = true); |
| 59 appModel.todos.add(new Todo('four (checked)')); | 58 appModel.todos.add(new Todo('four (checked)')); |
| 60 | 59 |
| 61 performMicrotaskCheckpoint(); | 60 performMicrotaskCheckpoint(); |
| 62 var body = query('body'); | 61 var body = query('body'); |
| 63 | 62 |
| 64 var label = findWithText(body, 'four (checked)'); | 63 var label = findWithText(body, 'four (checked)'); |
| 65 expect(label is LabelElement, isTrue, reason: 'text is in a label'); | 64 expect(label is LabelElement, isTrue, reason: 'text is in a label'); |
| 66 | 65 |
| 67 var host = findShadowHost(body, label.parentNode); | 66 var host = findShadowHost(body, label.parentNode); |
| 68 var node = host.parent.query('input'); | 67 var node = host.parent.query('input'); |
| 69 expect(node is InputElement, isTrue, reason: 'node is a checkbox'); | 68 expect(node is InputElement, isTrue, reason: 'node is a checkbox'); |
| 70 expect(node.type, 'checkbox', reason: 'node type is checkbox'); | 69 expect(node.type, 'checkbox', reason: 'node type is checkbox'); |
| 71 expect(node.checked, isFalse, reason: 'element is unchecked'); | 70 expect(node.checked, isFalse, reason: 'element is unchecked'); |
| 72 | 71 |
| 73 node.dispatchEvent(new MouseEvent('click', detail: 1)); | 72 node.dispatchEvent(new MouseEvent('click', detail: 1)); |
| 74 expect(node.checked, isTrue, reason: 'element is checked'); | 73 expect(node.checked, isTrue, reason: 'element is checked'); |
| 75 }); | 74 }); |
| 76 } | 75 } |
| OLD | NEW |