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

Side by Side Diff: sky/tests/dom/appendChild.sky

Issue 1212163009: Port remaining Sky tests to the new world (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: add Created 5 years, 5 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
« no previous file with comments | « sky/tests/dom/appendChild.dart ('k') | sky/tests/dom/attribute_collection.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <sky>
2 <import src="../resources/dom-utils.sky" as="DomUtils" />
3 <script>
4 import "../resources/third_party/unittest/unittest.dart";
5 import "../resources/unit.dart";
6
7 import "dart:sky";
8
9 void main() {
10 initUnit();
11
12 var childElementCount = DomUtils.childElementCount;
13 var childNodeCount = DomUtils.childNodeCount;
14
15 test("should throw with invalid arguments", () {
16 var parent = document.createElement("div");
17 expect(() {
18 parent.appendChild();
19 }, throws);
20 expect(() {
21 parent.appendChild(null);
22 }, throws);
23 expect(() {
24 parent.appendChild({tagName: "div"});
25 }, throws);
26 });
27
28 test("should insert children", () {
29 var parent = document.createElement("div");
30 var child1 = parent.appendChild(document.createElement("div"));
31 var child2 = parent.appendChild(new Text(" text "));
32 var child3 = parent.appendChild(new Text(" "));
33 var child4 = parent.appendChild(document.createElement("div"));
34 expect(child1.parentNode, equals(parent));
35 expect(child2.parentNode, equals(parent));
36 expect(child3.parentNode, equals(parent));
37 expect(child4.parentNode, equals(parent));
38 expect(childNodeCount(parent), equals(4));
39 expect(childElementCount(parent), equals(2));
40 });
41
42 test("should insert children with a fragment", () {
43 var fragment = document.createDocumentFragment();
44 var child1 = fragment.appendChild(document.createElement("div"));
45 var child2 = fragment.appendChild(new Text(" text "));
46 var child3 = fragment.appendChild(new Text(" "));
47 var child4 = fragment.appendChild(document.createElement("div"));
48 var parent = document.createElement("div");
49 parent.appendChild(fragment);
50 expect(child1.parentNode, equals(parent));
51 expect(child2.parentNode, equals(parent));
52 expect(child3.parentNode, equals(parent));
53 expect(child4.parentNode, equals(parent));
54 expect(childNodeCount(parent), equals(4));
55 expect(childElementCount(parent), equals(2));
56 });
57
58 // TODO(dart): These might be real bugs too.
59 // test("should throw when inserting a tree scope", () {
60 // var parent = document.createElement("div");
61 // var doc = new Document();
62 // var shadowRoot = document.createElement("span").ensureShadowRoot();
63 // expect(() {
64 // parent.appendChild(doc);
65 // }, throws);
66 // expect(() {
67 // parent.appendChild(shadowRoot);
68 // }, throws);
69 // expect(() {
70 // doc.appendChild(fragment);
71 // }, throws);
72 // });
73
74 // TODO(dart): These might be real bugs too.
75 // test("should throw when appending to a text", () {
76 // var parent = new Text();
77 // expect(() {
78 // parent.appendChild(document.createElement("div"));
79 // }, throws);
80 // });
81 }
82 </script>
83 </sky>
OLDNEW
« no previous file with comments | « sky/tests/dom/appendChild.dart ('k') | sky/tests/dom/attribute_collection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698