OLD | NEW |
1 library streams_test; | |
2 import 'package:unittest/unittest.dart'; | |
3 import 'package:unittest/html_config.dart'; | |
4 import 'dart:async'; | 1 import 'dart:async'; |
5 import 'dart:html'; | 2 import 'dart:html'; |
6 | 3 |
| 4 import 'package:expect/minitest.dart'; |
| 5 |
7 class StreamHelper { | 6 class StreamHelper { |
8 var _a; | 7 var _a; |
9 StreamHelper() { | 8 StreamHelper() { |
10 _a = new TextInputElement(); | 9 _a = new TextInputElement(); |
11 document.body.append(_a); | 10 document.body.append(_a); |
12 } | 11 } |
13 | 12 |
14 Element get element => _a; | 13 Element get element => _a; |
15 Stream<Event> get stream => _a.onFocus; | 14 Stream<Event> get stream => _a.onFocus; |
16 | 15 |
17 // Causes an event on a to be fired. | 16 // Causes an event on a to be fired. |
18 void pulse() { | 17 void pulse() { |
19 var event = new Event('focus'); | 18 var event = new Event('focus'); |
20 _a.dispatchEvent(event); | 19 _a.dispatchEvent(event); |
21 } | 20 } |
22 } | 21 } |
23 | 22 |
24 main() { | 23 main() { |
25 useHtmlConfiguration(); | |
26 | |
27 test('simple', () { | 24 test('simple', () { |
28 var helper = new StreamHelper(); | 25 var helper = new StreamHelper(); |
29 | 26 |
30 var callCount = 0; | 27 var callCount = 0; |
31 helper.stream.listen((Event e) { | 28 helper.stream.listen((Event e) { |
32 ++callCount; | 29 ++callCount; |
33 }); | 30 }); |
34 | 31 |
35 helper.pulse(); | 32 helper.pulse(); |
36 expect(callCount, 1); | 33 expect(callCount, 1); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 }); | 264 }); |
268 | 265 |
269 test('singleWhere', () { | 266 test('singleWhere', () { |
270 stream.singleWhere((_) => true).then((_) {}); | 267 stream.singleWhere((_) => true).then((_) {}); |
271 }); | 268 }); |
272 | 269 |
273 test('elementAt', () { | 270 test('elementAt', () { |
274 stream.elementAt(0).then((_) {}); | 271 stream.elementAt(0).then((_) {}); |
275 }); | 272 }); |
276 } | 273 } |
OLD | NEW |