Index: test/custom_element_test.dart |
diff --git a/test/custom_element_proxy_test.dart b/test/custom_element_test.dart |
similarity index 54% |
copy from test/custom_element_proxy_test.dart |
copy to test/custom_element_test.dart |
index 3437440bbef69543249e0ff77786beb3a4429b52..bd06fa71b62d325fd52556d013233bd7058d5a0c 100644 |
--- a/test/custom_element_proxy_test.dart |
+++ b/test/custom_element_test.dart |
@@ -1,35 +1,35 @@ |
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-library custom_element_proxy_test; |
+library web_components.test.custom_element_test; |
import 'dart:async'; |
import 'dart:html'; |
-import 'dart:js'; |
import 'package:initialize/initialize.dart' as init; |
import 'package:unittest/html_config.dart'; |
import 'package:unittest/unittest.dart'; |
-import 'package:web_components/custom_element_proxy.dart'; |
+import 'package:web_components/web_components.dart'; |
-@CustomElementProxy('basic-element') |
+@CustomElement('basic-element') |
class BasicElement extends HtmlElement { |
BasicElement.created() : super.created(); |
factory BasicElement() => document.createElement('basic-element'); |
+} |
+ |
+@CustomElement('child-element') |
+class ChildElement extends BasicElement { |
+ ChildElement.created() : super.created(); |
- bool get isBasicElement => |
- new JsObject.fromBrowserObject(this)['isBasicElement']; |
+ factory ChildElement() => document.createElement('child-element'); |
} |
-@CustomElementProxy('extended-element', extendsTag: 'input') |
+@CustomElement('extended-element', extendsTag: 'input') |
class ExtendedElement extends InputElement { |
ExtendedElement.created() : super.created(); |
factory ExtendedElement() => |
document.createElement('input', 'extended-element'); |
- |
- bool get isExtendedElement => |
- new JsObject.fromBrowserObject(this)['isExtendedElement']; |
} |
main() { |
@@ -42,22 +42,38 @@ main() { |
}); |
test('basic custom element', () { |
+ expect(document.querySelector('basic-element') is BasicElement, isTrue); |
container.append(new BasicElement()); |
- container.appendHtml('<basic-element></basic_element>'); |
+ container.appendHtml('<basic-element></basic-element>'); |
// TODO(jakemac): after appendHtml elements are upgraded asynchronously, |
// why? https://github.com/dart-lang/web-components/issues/4 |
return new Future(() {}).then((_) { |
var elements = container.querySelectorAll('basic-element'); |
expect(elements.length, 2); |
- for (BasicElement element in elements) { |
- print(element.outerHtml); |
- print(element.runtimeType); |
- expect(element.isBasicElement, isTrue); |
+ for (var element in elements) { |
+ expect(element is BasicElement, isTrue); |
+ } |
+ }); |
+ }); |
+ |
+ test('child custom element', () { |
+ expect(document.querySelector('child-element') is ChildElement, isTrue); |
+ container.append(new ChildElement()); |
+ container.appendHtml('<child-element></child-element>'); |
+ // TODO(jakemac): after appendHtml elements are upgraded asynchronously, |
+ // why? https://github.com/dart-lang/web-components/issues/4 |
+ return new Future(() {}).then((_) { |
+ var elements = container.querySelectorAll('child-element'); |
+ expect(elements.length, 2); |
+ for (var element in elements) { |
+ expect(element is ChildElement, isTrue); |
} |
}); |
}); |
- test('extends custom element', () { |
+ |
+ test('extends input element', () { |
+ expect(document.querySelector('input') is ExtendedElement, isTrue); |
container.append(new ExtendedElement()); |
container.appendHtml('<input is="extended-element" />'); |
// TODO(jakemac): after appendHtml elements are upgraded asynchronously, |
@@ -65,8 +81,8 @@ main() { |
return new Future(() {}).then((_) { |
var elements = container.querySelectorAll('input'); |
expect(elements.length, 2); |
- for (ExtendedElement element in elements) { |
- expect(element.isExtendedElement, isTrue); |
+ for (var element in elements) { |
+ expect(element is ExtendedElement, isTrue); |
} |
}); |
}); |