OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, 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 library template_wrappers_test; | |
6 | |
7 import 'dart:html'; | |
8 import 'dart:async'; | |
9 import 'dart:js' show context, JsObject; | |
10 import 'package:unittest/html_config.dart'; | |
11 import 'package:unittest/unittest.dart'; | |
12 import 'package:web_components/created_watcher.dart'; | |
13 | |
14 main() { | |
15 useHtmlConfiguration(); | |
16 | |
17 test('created_watcher is supported', () { | |
18 expect(isSupported, isTrue); | |
19 }); | |
20 | |
21 test('no events for previously upgraded elements', () { | |
justinfagnani
2014/06/06 23:33:05
so how do we create dart wrappers for previously u
Siggi Cherem (dart-lang)
2014/06/09 17:10:28
We could technically keep a buffer around but I'm
| |
22 var sA = watch('x-a').listen(expectAsync((e) { | |
23 fail('this should not be called'); | |
24 }, count: 0)); | |
25 var sB = watch('x-b', extendsTag: 'div').listen(expectAsync((e) { | |
26 fail('this should not be called'); | |
27 }, count: 0)); | |
28 var sC = watch('x-c').listen(expectAsync((e) { | |
29 fail('this should not be called'); | |
30 }, count: 0)); | |
31 return new Future.value().then((_) { | |
32 sA.cancel(); | |
33 sB.cancel(); | |
34 sC.cancel(); | |
35 }); | |
36 }); | |
37 | |
38 test('events seen when registration was done before', () { | |
39 var sA = watch('x-a').listen(expectAsync((e) { | |
40 expect(e is HtmlElement, isTrue); | |
41 expect(new JsObject.fromBrowserObject(e)['x'], 2); | |
42 })); | |
43 | |
44 var sB = watch('x-b', extendsTag: 'div').listen(expectAsync((e) { | |
45 expect(new JsObject.fromBrowserObject(e)['x'], 3); | |
46 })); | |
47 | |
48 var sC = watch('x-c').listen(expectAsync((e) { | |
49 fail('x-c is not registered yet'); | |
50 }, count: 0)); | |
51 | |
52 context.callMethod('addA'); | |
53 context.callMethod('addB'); | |
54 | |
55 return new Future.value().then((_) { | |
56 sA.cancel(); | |
57 sB.cancel(); | |
58 sC.cancel(); | |
59 }); | |
60 }); | |
61 | |
62 test('events seen when registration is done afterwards', () { | |
63 int lastValue; | |
64 var sC = watch('x-c').listen(expectAsync((e) { | |
65 lastValue = new JsObject.fromBrowserObject(e)['x']; | |
66 }, count: 2)); | |
67 | |
68 context.callMethod('registerC'); | |
69 expect(lastValue, 4); | |
70 context.callMethod('addC'); | |
71 expect(lastValue, 5); | |
72 return new Future.value().then((_) { | |
73 sC.cancel(); | |
74 }); | |
75 }); | |
76 } | |
OLD | NEW |