OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'dart:html'; | |
6 import 'package:unittest/unittest.dart'; | |
7 import 'package:observatory/src/elements/nav/menu.dart'; | |
8 | |
9 main() { | |
10 NavMenuElement.tag.ensureRegistration(); | |
11 | |
12 group('instantiation', () { | |
13 final label = 'custom-label'; | |
14 test('label', () { | |
15 final e = new NavMenuElement(label); | |
16 expect(e, isNotNull, reason: 'element correctly created'); | |
17 expect(e.label, equals(label), reason: 'element correctly created'); | |
18 }); | |
19 test('not last', () { | |
20 final e = new NavMenuElement(label, last: false); | |
21 expect(e, isNotNull, reason: 'element correctly created'); | |
22 expect(e.last, isFalse, reason: 'element correctly created'); | |
23 }); | |
24 test('last', () { | |
25 final e = new NavMenuElement(label, last: true); | |
26 expect(e, isNotNull, reason: 'element correctly created'); | |
27 expect(e.last, isTrue, reason: 'element correctly created'); | |
28 }); | |
29 }); | |
30 group('elements', () { | |
31 test('created', () async { | |
32 final label = 'custom-label'; | |
33 final e = new NavMenuElement(label); | |
34 document.body.append(e); | |
35 await e.onRendered.first; | |
36 expect(e.shadowRoot.children.length, isNonZero, reason: 'has elements'); | |
37 expect(e.shadowRoot.querySelector('content'), isNotNull, | |
38 reason: 'has content elements')
; | |
39 e.remove(); | |
40 await e.onRendered.first; | |
41 expect(e.shadowRoot.children.length, isZero, reason: 'is empty'); | |
42 }); | |
43 test('react to label change', () async { | |
44 final label1 = 'custom-label-1'; | |
45 final label2 = 'custom-label-2'; | |
46 final e = new NavMenuElement(label1); | |
47 document.body.append(e); | |
48 await e.onRendered.first; | |
49 expect(e.shadowRoot.innerHtml.contains(label1), isTrue); | |
50 expect(e.shadowRoot.innerHtml.contains(label2), isFalse); | |
51 e.label = label2; | |
52 await e.onRendered.first; | |
53 expect(e.shadowRoot.innerHtml.contains(label1), isFalse); | |
54 expect(e.shadowRoot.innerHtml.contains(label2), isTrue); | |
55 e.remove(); | |
56 await e.onRendered.first; | |
57 }); | |
58 test('react to last change', () async { | |
59 final label = 'custom-label'; | |
60 final e = new NavMenuElement(label, last: false); | |
61 document.body.append(e); | |
62 await e.onRendered.first; | |
63 expect(e.shadowRoot.innerHtml.contains('>'), isTrue); | |
64 e.last = true; | |
65 await e.onRendered.first; | |
66 expect(e.shadowRoot.innerHtml.contains('>'), isFalse); | |
67 e.last = false; | |
68 await e.onRendered.first; | |
69 expect(e.shadowRoot.innerHtml.contains('>'), isTrue); | |
70 e.remove(); | |
71 await e.onRendered.first; | |
72 }); | |
73 }); | |
74 } | |
OLD | NEW |