| 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 import 'dart:html'; | 5 import 'dart:html'; |
| 6 import 'package:polymer/polymer.dart'; | 6 import 'package:polymer/polymer.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'package:unittest/html_config.dart'; | 8 import 'package:unittest/html_config.dart'; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * This test runs the news example and checks the state of the initial page. | 11 * This test runs the news example and checks the state of the initial page. |
| 12 */ | 12 */ |
| 13 @initMethod _main() { | 13 main() { |
| 14 initPolymer(); |
| 14 useHtmlConfiguration(); | 15 useHtmlConfiguration(); |
| 15 | 16 |
| 16 extractLinks(nodes) => nodes.where((n) => n is Element) | 17 extractLinks(nodes) => nodes.where((n) => n is Element) |
| 17 .map((n) => n.query('a').href.split('/').last).toList(); | 18 .map((n) => n.query('a').href.split('/').last).toList(); |
| 18 | 19 |
| 19 test('initial state', () { | 20 test('initial state', () { |
| 20 final listComp = query('ul'); | 21 final listComp = query('ul'); |
| 21 final items = listComp.queryAll('li'); | 22 final items = listComp.queryAll('li'); |
| 22 expect(items.length, 6); | 23 expect(items.length, 6); |
| 23 expect(extractLinks(items), ['1', '2', '3', '4', '4', '5']); | 24 expect(extractLinks(items), ['1', '2', '3', '4', '4', '5']); |
| 24 expect(listComp.xtag is Polymer, true, | 25 expect(listComp.xtag is Polymer, true, |
| 25 reason: 'x-news should be created'); | 26 reason: 'x-news should be created'); |
| 26 | 27 |
| 27 final contents = listComp.shadowRoot.queryAll('content'); | 28 final contents = listComp.shadowRoot.queryAll('content'); |
| 28 expect(contents.length, 2, reason: 'news has 2 content tags'); | 29 expect(contents.length, 2, reason: 'news has 2 content tags'); |
| 29 expect(extractLinks(contents[0].getDistributedNodes()), | 30 expect(extractLinks(contents[0].getDistributedNodes()), |
| 30 ['3', '5'], reason: 'breaking stories first'); | 31 ['3', '5'], reason: 'breaking stories first'); |
| 31 expect(extractLinks(contents[1].getDistributedNodes()), | 32 expect(extractLinks(contents[1].getDistributedNodes()), |
| 32 ['1', '2', '4', '4'], reason: 'other stories after breaking stories'); | 33 ['1', '2', '4', '4'], reason: 'other stories after breaking stories'); |
| 33 }); | 34 }); |
| 34 } | 35 } |
| OLD | NEW |