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/ports.dart'; | 7 import 'package:observatory/src/elements/ports.dart'; |
8 import '../mocks.dart'; | 8 import '../mocks.dart'; |
9 | 9 |
10 main() { | 10 main() { |
(...skipping 12 matching lines...) Expand all Loading... |
23 expect(e.ports, equals(ports)); | 23 expect(e.ports, equals(ports)); |
24 }); | 24 }); |
25 test('elements created after attachment', () async { | 25 test('elements created after attachment', () async { |
26 const elements = const [ | 26 const elements = const [ |
27 const PortMock(name: 'port-1'), | 27 const PortMock(name: 'port-1'), |
28 const PortMock(name: 'port-2'), | 28 const PortMock(name: 'port-2'), |
29 const PortMock(name: 'port-3') | 29 const PortMock(name: 'port-3') |
30 ]; | 30 ]; |
31 const isolatePorts = const PortsMock(elements: elements); | 31 const isolatePorts = const PortsMock(elements: elements); |
32 final ports = new PortsRepositoryMock( | 32 final ports = new PortsRepositoryMock( |
33 getter: expectAsync((i) async { | 33 getter: expectAsync((i) async { |
34 expect(i, equals(isolate)); | 34 expect(i, equals(isolate)); |
35 return isolatePorts; | 35 return isolatePorts; |
36 }, count: 1) | 36 }, count: 1)); |
37 ); | |
38 final instances = new InstanceRepositoryMock(); | 37 final instances = new InstanceRepositoryMock(); |
39 final e = new PortsElement(vm, isolate, events, notifs, ports, instances); | 38 final e = new PortsElement(vm, isolate, events, notifs, ports, instances); |
40 document.body.append(e); | 39 document.body.append(e); |
41 await e.onRendered.first; | 40 await e.onRendered.first; |
42 expect(e.children.length, isNonZero, reason: 'has elements'); | 41 expect(e.children.length, isNonZero, reason: 'has elements'); |
43 expect(e.querySelectorAll('.port-number').length, equals(elements.length)); | 42 expect(e.querySelectorAll('.port-number').length, equals(elements.length)); |
44 e.remove(); | 43 e.remove(); |
45 await e.onRendered.first; | 44 await e.onRendered.first; |
46 expect(e.children.length, isZero, reason: 'is empty'); | 45 expect(e.children.length, isZero, reason: 'is empty'); |
47 }); | 46 }); |
48 } | 47 } |
OLD | NEW |