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

Side by Side Diff: pkg/polymer_expressions/test/syntax_test.dart

Issue 24096016: PolymerExpressions: fix for null iterators in comprehensions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
« no previous file with comments | « pkg/polymer_expressions/test/eval_test.dart ('k') | no next file » | 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 7
8 import 'package:polymer_expressions/polymer_expressions.dart'; 8 import 'package:polymer_expressions/polymer_expressions.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'package:unittest/html_enhanced_config.dart'; 10 import 'package:unittest/html_enhanced_config.dart';
11 import 'package:observe/observe.dart'; 11 import 'package:observe/observe.dart';
12 import 'package:mdv/mdv.dart' as mdv; 12 import 'package:mdv/mdv.dart' as mdv;
13 13
14 main() { 14 main() {
15 mdv.initialize(); 15 mdv.initialize();
16 useHtmlEnhancedConfiguration(); 16 useHtmlEnhancedConfiguration();
17 17
18 group('syntax', () { 18 group('PolymerExpressions', () {
19 var testDiv;
20
19 setUp(() { 21 setUp(() {
20 document.body.nodes.add(new Element.html(''' 22 document.body.append(testDiv = new DivElement());
23 });
24
25 tearDown(() {
26 testDiv.remove();
27 testDiv = null;
28 });
29
30 test('should make two-way bindings to inputs', () {
31 testDiv.nodes.add(new Element.html('''
21 <template id="test" bind> 32 <template id="test" bind>
22 <input id="input" value="{{ firstName }}"> 33 <input id="input" value="{{ firstName }}">
23 </template>''')); 34 </template>'''));
24 });
25
26 tearDown(() {
27 query('#test')..unbindAll()..remove();
28 });
29
30 test('should make two-way bindings to inputs', () {
31 var person = new Person('John', 'Messerly', ['A', 'B', 'C']); 35 var person = new Person('John', 'Messerly', ['A', 'B', 'C']);
32 query('#test') 36 query('#test')
33 ..bindingDelegate = new PolymerExpressions() 37 ..bindingDelegate = new PolymerExpressions()
34 ..model = person; 38 ..model = person;
35 return new Future.delayed(new Duration()).then((_) { 39 return new Future.delayed(new Duration()).then((_) {
36 InputElement input = query('#input'); 40 InputElement input = query('#input');
37 expect(input.value, 'John'); 41 expect(input.value, 'John');
38 input.focus(); 42 input.focus();
39 input.value = 'Justin'; 43 input.value = 'Justin';
40 input.blur(); 44 input.blur();
41 var event = new Event('change'); 45 var event = new Event('change');
42 // TODO(justin): figure out how to trigger keyboard events to test 46 // TODO(justin): figure out how to trigger keyboard events to test
43 // two-way bindings 47 // two-way bindings
44 }); 48 });
45 }); 49 });
46 50
51 test('should handle null collections in "in" expressions', () {
52 testDiv.nodes.add(new Element.html('''
53 <template id="test" bind>
54 <template repeat="{{ item in items }}">
55 {{ item }}
56 </template>
57 </template>'''));
58 query('#test')
59 ..bindingDelegate = new PolymerExpressions(globals: {'items': null})
60 ..model = null;
61 // the template should be the only node
62 expect(testDiv.nodes.length, 1);
63 expect(testDiv.nodes[0].id, 'test');
64 });
47 }); 65 });
48 } 66 }
49 67
50 class Person extends Object with ChangeNotifierMixin { 68 class Person extends Object with ChangeNotifierMixin {
51 static const _FIRST_NAME = const Symbol('firstName'); 69 static const _FIRST_NAME = const Symbol('firstName');
52 static const _LAST_NAME = const Symbol('lastName'); 70 static const _LAST_NAME = const Symbol('lastName');
53 static const _ITEMS = const Symbol('items'); 71 static const _ITEMS = const Symbol('items');
54 static const _GET_FULL_NAME = const Symbol('getFullName'); 72 static const _GET_FULL_NAME = const Symbol('getFullName');
55 73
56 String _firstName; 74 String _firstName;
(...skipping 21 matching lines...) Expand all
78 List<String> get items => _items; 96 List<String> get items => _items;
79 97
80 void set items(List<String> value) { 98 void set items(List<String> value) {
81 _items = value; 99 _items = value;
82 notifyChange(new PropertyChangeRecord(_ITEMS)); 100 notifyChange(new PropertyChangeRecord(_ITEMS));
83 } 101 }
84 102
85 String toString() => "Person(firstName: $_firstName, lastName: $_lastName)"; 103 String toString() => "Person(firstName: $_firstName, lastName: $_lastName)";
86 104
87 } 105 }
OLDNEW
« no previous file with comments | « pkg/polymer_expressions/test/eval_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698