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