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