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

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
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 setUp(() { 19 tearDown(() {
Jennifer Messerly 2013/09/16 19:43:47 hmm, not sure about this change. Is there a ration
justinfagnani 2013/09/16 20:02:57 Done.
20 document.body.nodes.clear();
21 });
22
23 test('should make two-way bindings to inputs', () {
20 document.body.nodes.add(new Element.html(''' 24 document.body.nodes.add(new Element.html('''
21 <template id="test" bind> 25 <template id="test" bind>
22 <input id="input" value="{{ firstName }}"> 26 <input id="input" value="{{ firstName }}">
23 </template>''')); 27 </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']); 28 var person = new Person('John', 'Messerly', ['A', 'B', 'C']);
32 query('#test') 29 query('#test')
33 ..bindingDelegate = new PolymerExpressions() 30 ..bindingDelegate = new PolymerExpressions()
34 ..model = person; 31 ..model = person;
35 return new Future.delayed(new Duration()).then((_) { 32 return new Future.delayed(new Duration()).then((_) {
36 InputElement input = query('#input'); 33 InputElement input = query('#input');
37 expect(input.value, 'John'); 34 expect(input.value, 'John');
38 input.focus(); 35 input.focus();
39 input.value = 'Justin'; 36 input.value = 'Justin';
40 input.blur(); 37 input.blur();
41 var event = new Event('change'); 38 var event = new Event('change');
42 // TODO(justin): figure out how to trigger keyboard events to test 39 // TODO(justin): figure out how to trigger keyboard events to test
43 // two-way bindings 40 // two-way bindings
44 }); 41 });
45 }); 42 });
46 43
44 test('should handle null collections in "in" expressions', () {
45 document.body.nodes.add(new Element.html('''
46 <template id="test" bind>
47 <template repeat="{{ item in items }}">
48 {{ item }}
49 </template>
50 </template>'''));
51 query('#test')
52 ..bindingDelegate = new PolymerExpressions(globals: {'items': null})
53 ..model = null;
54 // the template should be the only node
55 expect(document.body.nodes.length, 1);
56 expect(document.body.nodes[0].id, 'test');
57 });
47 }); 58 });
48 } 59 }
49 60
50 class Person extends Object with ChangeNotifierMixin { 61 class Person extends Object with ChangeNotifierMixin {
51 static const _FIRST_NAME = const Symbol('firstName'); 62 static const _FIRST_NAME = const Symbol('firstName');
52 static const _LAST_NAME = const Symbol('lastName'); 63 static const _LAST_NAME = const Symbol('lastName');
53 static const _ITEMS = const Symbol('items'); 64 static const _ITEMS = const Symbol('items');
54 static const _GET_FULL_NAME = const Symbol('getFullName'); 65 static const _GET_FULL_NAME = const Symbol('getFullName');
55 66
56 String _firstName; 67 String _firstName;
(...skipping 21 matching lines...) Expand all
78 List<String> get items => _items; 89 List<String> get items => _items;
79 90
80 void set items(List<String> value) { 91 void set items(List<String> value) {
81 _items = value; 92 _items = value;
82 notifyChange(new PropertyChangeRecord(_ITEMS)); 93 notifyChange(new PropertyChangeRecord(_ITEMS));
83 } 94 }
84 95
85 String toString() => "Person(firstName: $_firstName, lastName: $_lastName)"; 96 String toString() => "Person(firstName: $_firstName, lastName: $_lastName)";
86 97
87 } 98 }
OLDNEW
« pkg/polymer_expressions/lib/eval.dart ('K') | « 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