Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: samples/third_party/todomvc/test/listorder_test.dart

Issue 77373002: "Reverting 30388" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'package:polymer/polymer.dart'; 9 import 'package:polymer/polymer.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 import 'package:unittest/html_config.dart'; 11 import 'package:unittest/html_config.dart';
12 import '../web/model.dart'; 12 import '../web/elements/td_model.dart';
13 import '../web/elements/td_todos.dart';
14 import 'utils.dart';
13 15
14 /** 16 /**
15 * This test runs the TodoMVC app, adds a few elements, marks some as done, and 17 * This test runs the TodoMVC app, adds a few elements, marks some as done, and
16 * switches from back and forth between "Active" and "All". This will make some 18 * switches from back and forth between "Active" and "All". This will make some
17 * nodes to be hidden and readded to the page. 19 * nodes to be hidden and readded to the page.
18 */ 20 */
19 main() { 21 main() {
20 initPolymer(); 22 initPolymer();
21 useHtmlConfiguration(); 23 useHtmlConfiguration();
22 24
23 ShadowRoot root; 25 ShadowRoot root;
26 TodoModel model;
24 27
25 setUp(() => Polymer.onReady.then((_) { 28 setUp(() => Polymer.onReady.then((_) {
26 root = querySelector('todo-app').shadowRoot; 29 root = querySelector('td-todos').shadowRoot;
30 model = querySelector('td-model');
31 return onPropertyInit(model, 'items');
27 })); 32 }));
28 33
29 test('programmatically add items to model', () { 34 test('programmatically add items to model', () {
30 appModel.todos.addAll([ 35 model.items.addAll([
31 new Todo('one (unchecked)'), 36 new Todo('one (unchecked)'),
32 new Todo('two (checked)')..done = true, 37 new Todo('two (checked)')..completed = true,
33 new Todo('three (unchecked)') 38 new Todo('three (unchecked)')
34 ]); 39 ]);
35 Observable.dirtyCheck(); 40 Observable.dirtyCheck();
36 return window.animationFrame.then((_) { 41 return window.animationFrame.then((_) {
37 expect(root.querySelectorAll('#todo-list li[is=todo-row]').length, 3); 42 expect(root.querySelectorAll('#todo-list li[is=td-item]').length, 3);
38 43
39 // TODO(jmesserly): HTML Imports breaks relative hash links when the 44 // TODO(jmesserly): HTML Imports breaks relative hash links when the
40 // component is at a different path from the main HTML document. For now 45 // component is at a different path from the main HTML document. For now
41 // fix it programmatically. 46 // fix it programmatically.
42 for (var a in root.querySelectorAll('#filters > li > a')) { 47 for (var a in root.querySelectorAll('#filters > li > a')) {
43 a.href = '#${Uri.parse(a.href).fragment}'; 48 a.href = '#${Uri.parse(a.href).fragment}';
44 } 49 }
45 }); 50 });
46 }); 51 });
47 52
48 test('navigate to #/active', () { 53 test('navigate to #/active', () {
49 windowLocation.hash = '#/active'; 54 windowLocation.hash = '#/active';
50 return window.animationFrame.then((_) { 55 return window.animationFrame.then((_) {
51 expect(root.querySelectorAll('#todo-list li[is=todo-row]').length, 2); 56 expect(root.querySelectorAll('#todo-list li[is=td-item]').length, 2);
52 }); 57 });
53 }); 58 });
54 59
55 test('navigate to #/completed', () { 60 test('navigate to #/completed', () {
56 windowLocation.hash = '#/completed'; 61 windowLocation.hash = '#/completed';
57 return window.animationFrame.then((_) { 62 return window.animationFrame.then((_) {
58 expect(root.querySelectorAll('#todo-list li[is=todo-row]').length, 1); 63 expect(root.querySelectorAll('#todo-list li[is=td-item]').length, 1);
59 }); 64 });
60 }); 65 });
61 66
62 test('navigate back to #/', () { 67 test('navigate back to #/', () {
63 windowLocation.hash = '#/'; 68 windowLocation.hash = '#/';
64 return window.animationFrame.then((_) { 69 return window.animationFrame.then((_) {
65 expect(root.querySelectorAll('#todo-list li[is=todo-row]').length, 3); 70 expect(root.querySelectorAll('#todo-list li[is=td-item]').length, 3);
66 }); 71 });
67 }); 72 });
68 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698