forked from dart-archive/polymer-dart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproperty_change_test.dart
57 lines (43 loc) · 1.44 KB
/
property_change_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library polymer.test.property_change_test;
import 'dart:async';
import 'package:polymer/polymer.dart';
import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
// Dart note: this is a tad different from the JS code. We don't support putting
// expandos on Dart objects and then observing them. On the other hand, we want
// to make sure that superclass observers are correctly detected.
final _zonk = new Completer();
final _bar = new Completer();
@reflectable
class XBase extends PolymerElement {
@observable String zonk = '';
XBase.created() : super.created();
zonkChanged() {
expect(zonk, 'zonk', reason: 'change calls *Changed on superclass');
_zonk.complete();
}
}
@CustomTag('x-test')
class XTest extends XBase {
@observable String bar = '';
XTest.created() : super.created();
ready() {
bar = 'bar';
new Future(() {
zonk = 'zonk';
});
}
barChanged() {
expect(bar, 'bar', reason: 'change in ready calls *Changed');
_bar.complete();
}
}
main() => initPolymer().then((zone) => zone.run(() {
useHtmlConfiguration();
setUp(() => Polymer.onReady);
test('bar change detected', () => _bar.future);
test('zonk change detected', () => _zonk.future);
}));