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' hide Notification, NotificationEvent; | 5 import 'dart:html' hide Notification, NotificationEvent; |
6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
8 import 'package:observatory/src/elements/nav/notify.dart'; | 8 import 'package:observatory/src/elements/nav/notify.dart'; |
9 import 'package:observatory/src/elements/nav/notify_event.dart'; | 9 import 'package:observatory/src/elements/nav/notify_event.dart'; |
10 import 'package:observatory/src/elements/nav/notify_exception.dart'; | 10 import 'package:observatory/src/elements/nav/notify_exception.dart'; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 final e = new NavNotifyElement(repository); | 45 final e = new NavNotifyElement(repository); |
46 document.body.append(e); | 46 document.body.append(e); |
47 await e.onRendered.first; | 47 await e.onRendered.first; |
48 expect(repository.hasListeners, isTrue, reason: 'is listening'); | 48 expect(repository.hasListeners, isTrue, reason: 'is listening'); |
49 e.remove(); | 49 e.remove(); |
50 await e.onRendered.first; | 50 await e.onRendered.first; |
51 expect(repository.hasListeners, isFalse, reason: 'is no more listening'); | 51 expect(repository.hasListeners, isFalse, reason: 'is no more listening'); |
52 }); | 52 }); |
53 group('elements', () { | 53 group('elements', () { |
54 test('created after attachment', () async { | 54 test('created after attachment', () async { |
55 final repository = | 55 final repository = new NotificationRepositoryMock(list: [ |
56 new NotificationRepositoryMock(list: [ | 56 new ExceptionNotificationMock(exception: new Exception("ex")), |
57 new ExceptionNotificationMock(exception: new Exception("ex")), | 57 const EventNotificationMock(event: const VMUpdateEventMock(vm: vm)), |
58 const EventNotificationMock(event: const VMUpdateEventMock(vm: vm)), | 58 const EventNotificationMock(event: const VMUpdateEventMock(vm: vm)) |
59 const EventNotificationMock(event: const VMUpdateEventMock(vm: vm)) | 59 ]); |
60 ]); | |
61 final e = new NavNotifyElement(repository); | 60 final e = new NavNotifyElement(repository); |
62 document.body.append(e); | 61 document.body.append(e); |
63 await e.onRendered.first; | 62 await e.onRendered.first; |
64 expect(repository.listInvoked, isTrue, reason: 'should invoke list()'); | 63 expect(repository.listInvoked, isTrue, reason: 'should invoke list()'); |
65 expect(e.children.length, isNonZero, reason: 'has elements'); | 64 expect(e.children.length, isNonZero, reason: 'has elements'); |
66 expect(e.querySelectorAll(evTag).length, equals(2)); | 65 expect(e.querySelectorAll(evTag).length, equals(2)); |
67 expect(e.querySelectorAll(exTag).length, equals(1)); | 66 expect(e.querySelectorAll(exTag).length, equals(1)); |
68 e.remove(); | 67 e.remove(); |
69 await e.onRendered.first; | 68 await e.onRendered.first; |
70 expect(e.children.length, isZero, reason: 'is empty'); | 69 expect(e.children.length, isZero, reason: 'is empty'); |
71 }); | 70 }); |
72 test('react to notifyOnPause change', () async { | 71 test('react to notifyOnPause change', () async { |
73 final NotificationRepositoryMock repository = | 72 final NotificationRepositoryMock repository = |
74 new NotificationRepositoryMock(list: [ | 73 new NotificationRepositoryMock(list: [ |
75 new ExceptionNotificationMock(exception: new Exception("ex")), | 74 new ExceptionNotificationMock(exception: new Exception("ex")), |
76 const EventNotificationMock(event: const VMUpdateEventMock()), | 75 const EventNotificationMock(event: const VMUpdateEventMock()), |
77 const EventNotificationMock( | 76 const EventNotificationMock( |
78 event: const PauseStartEventMock(isolate: isolate)) | 77 event: const PauseStartEventMock(isolate: isolate)) |
79 ]); | 78 ]); |
80 final e = new NavNotifyElement(repository, notifyOnPause: true); | 79 final e = new NavNotifyElement(repository, notifyOnPause: true); |
81 document.body.append(e); | 80 document.body.append(e); |
82 await e.onRendered.first; | 81 await e.onRendered.first; |
83 expect(e.querySelectorAll(evTag).length, equals(2)); | 82 expect(e.querySelectorAll(evTag).length, equals(2)); |
84 expect(e.querySelectorAll(exTag).length, equals(1)); | 83 expect(e.querySelectorAll(exTag).length, equals(1)); |
85 e.notifyOnPause = false; | 84 e.notifyOnPause = false; |
86 await e.onRendered.first; | 85 await e.onRendered.first; |
87 expect(e.querySelectorAll(evTag).length, equals(1)); | 86 expect(e.querySelectorAll(evTag).length, equals(1)); |
88 expect(e.querySelectorAll(exTag).length, equals(1)); | 87 expect(e.querySelectorAll(exTag).length, equals(1)); |
89 e.notifyOnPause = true; | 88 e.notifyOnPause = true; |
(...skipping 20 matching lines...) Expand all Loading... |
110 repository.triggerChangeEvent(); | 109 repository.triggerChangeEvent(); |
111 await e.onRendered.first; | 110 await e.onRendered.first; |
112 expect(e.querySelectorAll(evTag).length, equals(2)); | 111 expect(e.querySelectorAll(evTag).length, equals(2)); |
113 expect(e.querySelectorAll(exTag).length, equals(1)); | 112 expect(e.querySelectorAll(exTag).length, equals(1)); |
114 e.remove(); | 113 e.remove(); |
115 await e.onRendered.first; | 114 await e.onRendered.first; |
116 expect(e.children.length, isZero, reason: 'is empty'); | 115 expect(e.children.length, isZero, reason: 'is empty'); |
117 }); | 116 }); |
118 }); | 117 }); |
119 } | 118 } |
OLD | NEW |