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

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

Issue 794473002: Delete polymer from the Dart repo (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
« no previous file with comments | « pkg/polymer/test/auto_binding_test.html ('k') | pkg/polymer/test/bind_mdv_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library polymer.test.bind_mdv_test;
6
7 import 'dart:async';
8 import 'dart:html';
9 import 'package:template_binding/template_binding.dart';
10 import 'package:observe/observe.dart';
11 import 'package:observe/mirrors_used.dart'; // make test smaller.
12 import 'package:unittest/html_config.dart';
13 import 'package:unittest/unittest.dart';
14 import 'package:web_components/polyfill.dart';
15
16 main() {
17 useHtmlConfiguration();
18
19 var registered = customElementsReady.then((_) {
20 document.registerElement('my-div', MyDivElement);
21 });
22
23 setUp(() => registered);
24
25 group('bindModel', bindModelTests);
26 }
27
28 bindModelTests() {
29 var div;
30
31 setUp(() {
32 div = new MyDivElement();
33 document.body.append(div);
34 });
35
36 tearDown(() {
37 div.remove();
38 });
39
40 parseAndBindHTML(html, model) =>
41 templateBind(new Element.tag('template')
42 ..setInnerHtml(html, treeSanitizer: const NullTreeSanitizer()))
43 .createInstance(model);
44
45 test('bindModel', () {
46 var fragment = parseAndBindHTML('<div id="a" foo="{{bar}}"></div>', div);
47 div.append(fragment);
48 var a = div.query('#a');
49
50 div.bar = 5;
51 return onAttributeChange(a).then((_) {
52 expect(a.attributes['foo'], '5');
53 div.bar = 8;
54 return onAttributeChange(a).then((_) {
55 expect(a.attributes['foo'], '8');
56 });
57 });
58 });
59
60 test('bind input', () {
61 var fragment = parseAndBindHTML('<input value="{{bar}}" />', div);
62 div.append(fragment);
63 var a = div.query('input');
64
65 div.bar = 'hello';
66 // TODO(sorvell): fix this when observe-js lets us explicitly listen for
67 // a change on input.value
68 Observable.dirtyCheck();
69 return new Future.microtask(() {
70 expect(a.value, 'hello');
71 });
72 });
73 }
74
75 class MyDivElement extends HtmlElement with Observable {
76 factory MyDivElement() => new Element.tag('my-div');
77 MyDivElement.created() : super.created();
78 @observable var bar;
79 }
80
81 class NullTreeSanitizer implements NodeTreeSanitizer {
82 const NullTreeSanitizer();
83 void sanitizeTree(Node node) {}
84 }
85
86 Future onAttributeChange(Element node) {
87 var completer = new Completer();
88 new MutationObserver((records, observer) {
89 observer.disconnect();
90 completer.complete();
91 })..observe(node, attributes: true);
92 scheduleMicrotask(Observable.dirtyCheck);
93 return completer.future;
94 }
OLDNEW
« no previous file with comments | « pkg/polymer/test/auto_binding_test.html ('k') | pkg/polymer/test/bind_mdv_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698