Index: pkg/polymer/test/bind_mdv_test.dart |
diff --git a/pkg/polymer/test/bind_mdv_test.dart b/pkg/polymer/test/bind_mdv_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f799ee87badffb9a4ef42a19e36a2e15a727a54d |
--- /dev/null |
+++ b/pkg/polymer/test/bind_mdv_test.dart |
@@ -0,0 +1,72 @@ |
+// 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. |
+ |
+// 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.bind_mdv_test; |
+ |
+import 'dart:html'; |
+import 'package:custom_element/custom_element.dart' show CustomElement; |
+import 'package:mdv/mdv.dart' as mdv; |
+import 'package:observe/observe.dart'; |
+import 'package:observe/src/microtask.dart' show runMicrotask; |
+import 'package:polymer/platform.dart' as Platform; |
+import 'package:unittest/html_config.dart'; |
+import 'package:unittest/unittest.dart'; |
+ |
+main() { |
+ mdv.initialize(); |
+ useHtmlConfiguration(); |
+ group('bindModel', bindModelTests); |
+} |
+ |
+bindModelTests() { |
+ |
+ parseAndBindHTML(html, model) => |
+ (new Element.tag('template') |
+ ..setInnerHtml(html, treeSanitizer: const NullTreeSanitizer())) |
+ .createInstance(model); |
+ |
+ test('bindModel', () => runMicrotask(() { |
+ var test = new MyDivElement()..host = new DivElement(); |
+ var fragment = parseAndBindHTML('<div id="a" foo="{{bar}}"></div>', test); |
+ test.append(fragment); |
+ var a = test.query('#a'); |
+ |
+ test.bar = 5; |
+ Platform.flush(); |
+ Platform.endOfMicrotask(expectAsync0(() { |
+ expect(a.attributes['foo'], '5'); |
+ test.bar = 8; |
+ Platform.flush(); |
+ Platform.endOfMicrotask(expectAsync0(() { |
+ expect(a.attributes['foo'], '8'); |
+ })); |
+ })); |
+ })); |
+ |
+ test('bind input', () => runMicrotask(() { |
+ var test = new MyDivElement()..host = new DivElement(); |
+ var fragment = parseAndBindHTML('<input value="{{bar}}" />', test); |
+ test.append(fragment); |
+ var a = test.query('input'); |
+ |
+ test.bar = 'hello'; |
+ Platform.flush(); |
+ Platform.endOfMicrotask(expectAsync0(() { |
+ expect(a.value, 'hello'); |
+ })); |
+ })); |
+} |
+ |
+class MyDivElement extends CustomElement with ObservableMixin { |
+ @observable var bar; |
+} |
+ |
+class NullTreeSanitizer implements NodeTreeSanitizer { |
+ const NullTreeSanitizer(); |
+ void sanitizeTree(Node node) {} |
+} |