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

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

Issue 41383002: fix binding to $ from polymer templates (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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/lib/src/instance.dart ('k') | pkg/polymer/test/bind_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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:html'; 6 import 'dart:html';
7 import 'package:polymer/polymer.dart'; 7 import 'package:polymer/polymer.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'package:unittest/html_config.dart'; 9 import 'package:unittest/html_config.dart';
10 import 'package:unittest/matcher.dart'; 10 import 'package:unittest/matcher.dart';
11 11
12 @CustomTag('x-bar')
13 class XBar extends PolymerElement {
14 XBar.created() : super.created();
15
16 get testValue => true;
17 }
18
12 @CustomTag('x-foo') 19 @CustomTag('x-foo')
13 class XFoo extends PolymerElement { 20 class XFoo extends PolymerElement {
14 @observable var foo = 'foo!'; 21 @observable var foo = 'foo!';
15 final _ready = new Completer(); 22 final _testDone = new Completer();
16 Future onTestDone; 23 Future get onTestDone => _testDone.future;
17 24
18 XFoo.created() : super.created() { 25 XFoo.created() : super.created();
19 onTestDone = _ready.future.then(_runTest);
20 }
21 26
22 _runTest(_) { 27 _runTest(_) {
28 expect($['bindId'].text.trim(), 'bar!');
29
23 expect(foo, $['foo'].attributes['foo']); 30 expect(foo, $['foo'].attributes['foo']);
24 expect($['bool'].attributes['foo'], ''); 31 expect($['bool'].attributes['foo'], '');
25 expect($['bool'].attributes, isNot(contains('foo?'))); 32 expect($['bool'].attributes, isNot(contains('foo?')));
26 expect($['content'].innerHtml, foo); 33 expect($['content'].innerHtml, foo);
27 34
28 expect(foo, $['bar'].attributes['foo']); 35 expect(foo, $['bar'].attributes['foo']);
29 expect($['barBool'].attributes['foo'], ''); 36 expect($['barBool'].attributes['foo'], '');
30 expect($['barBool'].attributes, isNot(contains('foo?'))); 37 expect($['barBool'].attributes, isNot(contains('foo?')));
31 expect($['barContent'].innerHtml, foo); 38 expect($['barContent'].innerHtml, foo);
39 _testDone.complete();
32 } 40 }
33 41
34 ready() => _ready.complete(); 42 ready() {
43 onMutation($['bindId']).then(_runTest);
44 }
35 } 45 }
36 46
37 main() { 47 main() {
38 initPolymer(); 48 initPolymer();
39 useHtmlConfiguration(); 49 useHtmlConfiguration();
40 50
41 setUp(() => Polymer.onReady); 51 setUp(() => Polymer.onReady);
42 52
43 test('ready called', () => query('x-foo').onTestDone); 53 test('ready called', () => query('x-foo').onTestDone);
44 } 54 }
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/instance.dart ('k') | pkg/polymer/test/bind_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698