OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:async'; |
| 6 import 'dart:html'; |
| 7 import 'package:polymer/polymer.dart'; |
| 8 import 'package:polymer/platform.dart' as Platform; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 import 'package:unittest/html_config.dart'; |
| 11 |
| 12 @CustomTag('x-test') |
| 13 class XTest extends PolymerElement { |
| 14 @observable List list; |
| 15 |
| 16 final _inserted = new Completer(); |
| 17 Future onTestDone; |
| 18 |
| 19 created() { |
| 20 super.created(); |
| 21 onTestDone = _inserted.future.then(_runTest); |
| 22 } |
| 23 |
| 24 inserted() => _inserted.complete(); |
| 25 |
| 26 _runTest(_) { |
| 27 list = [ |
| 28 {'name': 'foo'}, |
| 29 {'name': 'bar'} |
| 30 ]; |
| 31 |
| 32 Platform.flush(); |
| 33 Platform.endOfMicrotask(expectAsync0(() { |
| 34 // tickle SD polyfill |
| 35 offsetHeight; |
| 36 var children = this.$['echo'].children; |
| 37 expect(children[0].localName, 'template', reason: |
| 38 'shadowDOM dynamic distribution via template'); |
| 39 expect(children[1].text, 'foo', reason: |
| 40 'shadowDOM dynamic distribution via template'); |
| 41 expect(children[2].text, 'bar', reason: |
| 42 'shadowDOM dynamic distribution via template'); |
| 43 |
| 44 // TODO(jmesserly): restore this if we get the JS interop capability. |
| 45 /* |
| 46 if (window.ShadowDOMPolyfill) { |
| 47 var actualChildren = this.$.echo.impl.children; |
| 48 chai.assert.equal(actualChildren.length, 4, |
| 49 'shadowDOMPolyfill distributes expected number of actual children.'); |
| 50 } |
| 51 */ |
| 52 })); |
| 53 } |
| 54 } |
| 55 |
| 56 main() { |
| 57 useHtmlConfiguration(); |
| 58 |
| 59 test('inserted called', () => query('x-test').xtag.onTestDone); |
| 60 } |
OLD | NEW |