Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: pkg/polymer/test/bind_mdv_test.dart

Issue 25740006: port polymer data binding tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
6 // for details. All rights reserved. Use of this source code is governed by a
7 // BSD-style license that can be found in the LICENSE file.
8
9 library polymer.test.bind_mdv_test;
10
11 import 'dart:html';
12 import 'package:custom_element/custom_element.dart' show CustomElement;
13 import 'package:mdv/mdv.dart' as mdv;
14 import 'package:observe/observe.dart';
15 import 'package:observe/src/microtask.dart' show runMicrotask;
16 import 'package:polymer/platform.dart' as Platform;
17 import 'package:unittest/html_config.dart';
18 import 'package:unittest/unittest.dart';
19
20 main() {
21 mdv.initialize();
22 useHtmlConfiguration();
23 group('bindModel', bindModelTests);
24 }
25
26 bindModelTests() {
27
28 parseAndBindHTML(html, model) =>
29 (new Element.tag('template')
30 ..setInnerHtml(html, treeSanitizer: const NullTreeSanitizer()))
31 .createInstance(model);
32
33 test('bindModel', () => runMicrotask(() {
34 var test = new MyDivElement()..host = new DivElement();
35 var fragment = parseAndBindHTML('<div id="a" foo="{{bar}}"></div>', test);
36 test.append(fragment);
37 var a = test.query('#a');
38
39 test.bar = 5;
40 Platform.flush();
41 Platform.endOfMicrotask(expectAsync0(() {
42 expect(a.attributes['foo'], '5');
43 test.bar = 8;
44 Platform.flush();
45 Platform.endOfMicrotask(expectAsync0(() {
46 expect(a.attributes['foo'], '8');
47 }));
48 }));
49 }));
50
51 test('bind input', () => runMicrotask(() {
52 var test = new MyDivElement()..host = new DivElement();
53 var fragment = parseAndBindHTML('<input value="{{bar}}" />', test);
54 test.append(fragment);
55 var a = test.query('input');
56
57 test.bar = 'hello';
58 Platform.flush();
59 Platform.endOfMicrotask(expectAsync0(() {
60 expect(a.value, 'hello');
61 }));
62 }));
63 }
64
65 class MyDivElement extends CustomElement with ObservableMixin {
66 @observable var bar;
67 }
68
69 class NullTreeSanitizer implements NodeTreeSanitizer {
70 const NullTreeSanitizer();
71 void sanitizeTree(Node node) {}
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698