OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
7 import 'package:observatory/src/elements/nav/menu_item.dart'; | 7 import 'package:observatory/src/elements/nav/menu_item.dart'; |
8 | 8 |
9 main() { | 9 main() { |
10 NavMenuItemElement.tag.ensureRegistration(); | 10 NavMenuItemElement.tag.ensureRegistration(); |
(...skipping 14 matching lines...) Expand all Loading... |
25 }); | 25 }); |
26 group('elements', () { | 26 group('elements', () { |
27 test('created', () async { | 27 test('created', () async { |
28 final label = 'custom-label'; | 28 final label = 'custom-label'; |
29 final e = new NavMenuItemElement(label); | 29 final e = new NavMenuItemElement(label); |
30 e.content = [document.createElement('content')]; | 30 e.content = [document.createElement('content')]; |
31 document.body.append(e); | 31 document.body.append(e); |
32 await e.onRendered.first; | 32 await e.onRendered.first; |
33 expect(e.children.length, isNonZero, reason: 'has elements'); | 33 expect(e.children.length, isNonZero, reason: 'has elements'); |
34 expect(e.querySelector('content'), isNotNull, | 34 expect(e.querySelector('content'), isNotNull, |
35 reason: 'has content elements')
; | 35 reason: 'has content elements'); |
36 e.remove(); | 36 e.remove(); |
37 await e.onRendered.first; | 37 await e.onRendered.first; |
38 expect(e.children.length, isZero, reason: 'is empty'); | 38 expect(e.children.length, isZero, reason: 'is empty'); |
39 }); | 39 }); |
40 test('react to label change', () async { | 40 test('react to label change', () async { |
41 final label1 = 'custom-label-1'; | 41 final label1 = 'custom-label-1'; |
42 final label2 = 'custom-label-2'; | 42 final label2 = 'custom-label-2'; |
43 final e = new NavMenuItemElement(label1); | 43 final e = new NavMenuItemElement(label1); |
44 document.body.append(e); | 44 document.body.append(e); |
45 await e.onRendered.first; | 45 await e.onRendered.first; |
(...skipping 17 matching lines...) Expand all Loading... |
63 expect(e.innerHtml.contains(link2), isFalse); | 63 expect(e.innerHtml.contains(link2), isFalse); |
64 e.link = link2; | 64 e.link = link2; |
65 await e.onRendered.first; | 65 await e.onRendered.first; |
66 expect(e.innerHtml.contains(link1), isFalse); | 66 expect(e.innerHtml.contains(link1), isFalse); |
67 expect(e.innerHtml.contains(link2), isTrue); | 67 expect(e.innerHtml.contains(link2), isTrue); |
68 e.remove(); | 68 e.remove(); |
69 await e.onRendered.first; | 69 await e.onRendered.first; |
70 }); | 70 }); |
71 }); | 71 }); |
72 } | 72 } |
OLD | NEW |