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 import 'package:observatory/src/elements/nav/top_menu.dart'; | |
9 | |
10 main() { | |
11 NavTopMenuElement.tag.ensureRegistration(); | |
12 | |
13 final tag = NavMenuElement.tag.name; | |
14 | |
15 group('instantiation', () { | |
16 test('default', () { | |
17 final e = new NavTopMenuElement(); | |
18 expect(e, isNotNull, reason: 'element correctly created'); | |
19 }); | |
20 test('not last', () { | |
21 final e = new NavTopMenuElement(last: false); | |
22 expect(e, isNotNull, reason: 'element correctly created'); | |
23 expect(e.last, isFalse, reason: 'element correctly created'); | |
24 }); | |
25 test('last', () { | |
26 final e = new NavTopMenuElement(last: true); | |
27 expect(e, isNotNull, reason: 'element correctly created'); | |
28 expect(e.last, isTrue, reason: 'element correctly created'); | |
29 }); | |
30 }); | |
31 group('elements', () { | |
32 test('created', () async { | |
33 final e = new NavTopMenuElement(); | |
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 last change', () async { | |
44 final e = new NavTopMenuElement(last: false); | |
45 document.body.append(e); | |
46 await e.onRendered.first; | |
47 expect((e.shadowRoot.querySelector(tag) as NavMenuElement).last, isFalse); | |
48 e.last = true; | |
49 await e.onRendered.first; | |
50 expect((e.shadowRoot.querySelector(tag) as NavMenuElement).last, isTrue); | |
51 e.last = false; | |
52 await e.onRendered.first; | |
53 expect((e.shadowRoot.querySelector(tag) as NavMenuElement).last, isFalse); | |
54 e.remove(); | |
55 await e.onRendered.first; | |
56 }); | |
57 }); | |
58 } | |
OLD | NEW |