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 library template_binding.test.template_binding_test; | 5 library template_binding.test.template_binding_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:html'; | 9 import 'dart:html'; |
10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
11 import 'package:observe/observe.dart'; | 11 import 'package:observe/observe.dart'; |
12 import 'package:template_binding/template_binding.dart'; | 12 import 'package:template_binding/template_binding.dart'; |
13 import 'package:unittest/html_config.dart'; | 13 import 'package:unittest/html_config.dart'; |
14 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
15 | 15 |
16 // TODO(jmesserly): merge this file? | 16 // TODO(jmesserly): merge this file? |
17 import 'binding_syntax.dart' show syntaxTests; | 17 import 'binding_syntax.dart' show syntaxTests; |
18 import 'utils.dart'; | 18 import 'utils.dart'; |
19 | 19 |
20 // Note: this file ported from | 20 // Note: this file ported from |
21 // https://github.com/Polymer/TemplateBinding/blob/ed3266266e751b5ab1f75f8e0509d
0d5f0ef35d8/tests/tests.js | 21 // https://github.com/Polymer/TemplateBinding/blob/ed3266266e751b5ab1f75f8e0509d
0d5f0ef35d8/tests/tests.js |
22 | 22 |
23 // TODO(jmesserly): submit a small cleanup patch to original. I fixed some | 23 // TODO(jmesserly): submit a small cleanup patch to original. I fixed some |
24 // cases where "div" and "t" were unintentionally using the JS global scope; | 24 // cases where "div" and "t" were unintentionally using the JS global scope; |
25 // look for "assertNodesAre". | 25 // look for "assertNodesAre". |
26 | 26 |
27 main() { | 27 main() { |
28 useHtmlConfiguration(); | 28 useHtmlConfiguration(); |
29 | 29 |
30 setUp(() { | 30 // Load MutationObserver polyfill in case IE needs it. |
| 31 var script = new ScriptElement() |
| 32 ..src = '/root_dart/pkg/mutation_observer/lib/mutation_observer.min.js'; |
| 33 var polyfillLoaded = script.onLoad.first; |
| 34 document.head.append(script); |
| 35 |
| 36 setUp(() => polyfillLoaded.then((_) { |
31 document.body.append(testDiv = new DivElement()); | 37 document.body.append(testDiv = new DivElement()); |
32 }); | 38 })); |
33 | 39 |
34 tearDown(() { | 40 tearDown(() { |
35 testDiv.remove(); | 41 testDiv.remove(); |
36 testDiv = null; | 42 testDiv = null; |
37 }); | 43 }); |
38 | 44 |
| 45 test('MutationObserver is supported', () { |
| 46 expect(MutationObserver.supported, true, reason: 'polyfill was loaded.'); |
| 47 }); |
| 48 |
39 group('Template Instantiation', templateInstantiationTests); | 49 group('Template Instantiation', templateInstantiationTests); |
40 | 50 |
41 group('Binding Delegate API', () { | 51 group('Binding Delegate API', () { |
42 group('with Observable', () { | 52 group('with Observable', () { |
43 syntaxTests(([f, b]) => new FooBarModel(f, b)); | 53 syntaxTests(([f, b]) => new FooBarModel(f, b)); |
44 }); | 54 }); |
45 | 55 |
46 group('with ChangeNotifier', () { | 56 group('with ChangeNotifier', () { |
47 syntaxTests(([f, b]) => new FooBarNotifyModel(f, b)); | 57 syntaxTests(([f, b]) => new FooBarNotifyModel(f, b)); |
48 }); | 58 }); |
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 prepareBinding(path, name, node) { | 1864 prepareBinding(path, name, node) { |
1855 if (name != 'text' || path != 'age') return null; | 1865 if (name != 'text' || path != 'age') return null; |
1856 | 1866 |
1857 return (model, node) { | 1867 return (model, node) { |
1858 expect(model['age'], expectedAge); | 1868 expect(model['age'], expectedAge); |
1859 count++; | 1869 count++; |
1860 return model; | 1870 return model; |
1861 }; | 1871 }; |
1862 } | 1872 } |
1863 } | 1873 } |
OLD | NEW |