| OLD | NEW |
| 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:html'; | 5 import 'dart:html'; |
| 6 | 6 |
| 7 import 'package:mdv/mdv.dart' as mdv; | |
| 8 import 'package:observe/observe.dart'; | 7 import 'package:observe/observe.dart'; |
| 9 import 'package:observe/src/microtask.dart'; | 8 import 'package:observe/src/microtask.dart'; |
| 10 import 'package:polymer_expressions/polymer_expressions.dart'; | 9 import 'package:polymer_expressions/polymer_expressions.dart'; |
| 10 import 'package:template_binding/template_binding.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 import 'package:unittest/html_enhanced_config.dart'; | 12 import 'package:unittest/html_enhanced_config.dart'; |
| 13 | 13 |
| 14 main() { | 14 main() { |
| 15 mdv.initialize(); | |
| 16 useHtmlEnhancedConfiguration(); | 15 useHtmlEnhancedConfiguration(); |
| 17 | 16 |
| 18 var testDiv; | 17 var testDiv; |
| 19 group('enumerate', () { | 18 group('enumerate', () { |
| 20 setUp(() { | 19 setUp(() { |
| 21 testDiv = new Element.html(''' | 20 testDiv = new Element.html(''' |
| 22 <div id="test"> | 21 <div id="test"> |
| 23 <template bind> | 22 <template bind> |
| 24 <template repeat="{{entry in this | enumerate}}"> | 23 <template repeat="{{entry in this | enumerate}}"> |
| 25 <div>Item {{ entry.index }} is {{ entry.value }}</div> | 24 <div>Item {{ entry.index }} is {{ entry.value }}</div> |
| 26 </template> | 25 </template> |
| 27 </template> | 26 </template> |
| 28 </div>'''); | 27 </div>'''); |
| 29 document.body.nodes.add(testDiv); | 28 document.body.nodes.add(testDiv); |
| 30 }); | 29 }); |
| 31 | 30 |
| 32 tearDown(() { | 31 tearDown(() { |
| 33 testDiv..unbindAll()..remove(); | 32 nodeBind(testDiv).unbindAll(); |
| 33 testDiv.remove(); |
| 34 testDiv = null; | 34 testDiv = null; |
| 35 }); | 35 }); |
| 36 | 36 |
| 37 test('should enumerate item and index', wrapMicrotask(() { | 37 test('should enumerate item and index', wrapMicrotask(() { |
| 38 testDiv.query('template') | 38 templateBind(testDiv.query('template')) |
| 39 ..bindingDelegate = new PolymerExpressions() | 39 ..bindingDelegate = new PolymerExpressions() |
| 40 ..model = toObservable( | 40 ..model = toObservable( |
| 41 ['hello', 'from', 'polymer', 'expressions']); | 41 ['hello', 'from', 'polymer', 'expressions']); |
| 42 | 42 |
| 43 performMicrotaskCheckpoint(); | 43 performMicrotaskCheckpoint(); |
| 44 | 44 |
| 45 expect(testDiv.queryAll('div').map((n) => n.text), [ | 45 expect(testDiv.queryAll('div').map((n) => n.text), [ |
| 46 'Item 0 is hello', | 46 'Item 0 is hello', |
| 47 'Item 1 is from', | 47 'Item 1 is from', |
| 48 'Item 2 is polymer', | 48 'Item 2 is polymer', |
| 49 'Item 3 is expressions', | 49 'Item 3 is expressions', |
| 50 ]); | 50 ]); |
| 51 })); | 51 })); |
| 52 }); | 52 }); |
| 53 } | 53 } |
| OLD | NEW |