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

Side by Side Diff: sky/tests/dom/replaceChild.dart

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/ownerScope.sky ('k') | sky/tests/dom/replaceChild.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <sky> 1 import "../resources/dom_utils.dart";
2 <import src="../resources/dom-utils.sky" as="DomUtils" />
3 <script>
4 import "../resources/third_party/unittest/unittest.dart"; 2 import "../resources/third_party/unittest/unittest.dart";
5 import "../resources/unit.dart"; 3 import "../resources/unit.dart";
6 4
7 import "dart:sky"; 5 import "dart:sky";
8 6
9 void main() { 7 void main() {
10 initUnit(); 8 initUnit();
11 9
12 var childElementCount = DomUtils.childElementCount; 10 var document = new Document();
13 var childNodeCount = DomUtils.childNodeCount;
14 11
15 test("should replace elements", () { 12 test("should replace elements", () {
16 var parent = document.createElement("div"); 13 var parent = document.createElement("div");
17 var oldChild = parent.appendChild(document.createElement("div")); 14 var oldChild = parent.appendChild(document.createElement("div"));
18 var newChild = document.createElement("div"); 15 var newChild = document.createElement("div");
19 oldChild.replaceWith([newChild]); 16 oldChild.replaceWith([newChild]);
20 expect(oldChild.parentNode, isNull); 17 expect(oldChild.parentNode, isNull);
21 expect(newChild.parentNode, equals(parent)); 18 expect(newChild.parentNode, equals(parent));
22 }); 19 });
23 20
24 test("should replace text", () { 21 test("should replace text", () {
25 var parent = document.createElement("div"); 22 var parent = document.createElement("div");
26 var oldChild = parent.appendChild(new Text(" it's a text ")); 23 var oldChild = parent.appendChild(document.createText(" it's a text "));
27 var newChild = document.createElement("div"); 24 var newChild = document.createElement("div");
28 oldChild.replaceWith([newChild]); 25 oldChild.replaceWith([newChild]);
29 expect(oldChild.parentNode, isNull); 26 expect(oldChild.parentNode, isNull);
30 expect(newChild.parentNode, equals(parent)); 27 expect(newChild.parentNode, equals(parent));
31 }); 28 });
32 29
33 test("should replace children with a fragment", () { 30 test("should replace children with a fragment", () {
34 var fragment = document.createDocumentFragment(); 31 var fragment = document.createDocumentFragment();
35 var child1 = fragment.appendChild(document.createElement("div")); 32 var child1 = fragment.appendChild(document.createElement("div"));
36 var child2 = fragment.appendChild(new Text(" text ")); 33 var child2 = fragment.appendChild(document.createText(" text "));
37 var child3 = fragment.appendChild(new Text(" ")); 34 var child3 = fragment.appendChild(document.createText(" "));
38 var child4 = fragment.appendChild(document.createElement("div")); 35 var child4 = fragment.appendChild(document.createElement("div"));
39 var parent = document.createElement("div"); 36 var parent = document.createElement("div");
40 var oldChild = parent.appendChild(document.createElement("div")); 37 var oldChild = parent.appendChild(document.createElement("div"));
41 var lastChild = parent.appendChild(document.createElement("div")); 38 var lastChild = parent.appendChild(document.createElement("div"));
42 oldChild.replaceWith([fragment]); 39 oldChild.replaceWith([fragment]);
43 expect(child1.parentNode, equals(parent)); 40 expect(child1.parentNode, equals(parent));
44 expect(child2.parentNode, equals(parent)); 41 expect(child2.parentNode, equals(parent));
45 expect(child3.parentNode, equals(parent)); 42 expect(child3.parentNode, equals(parent));
46 expect(child4.parentNode, equals(parent)); 43 expect(child4.parentNode, equals(parent));
47 expect(oldChild.parentNode, isNull); 44 expect(oldChild.parentNode, isNull);
(...skipping 17 matching lines...) Expand all
65 // }, throws); 62 // }, throws);
66 // }); 63 // });
67 64
68 // test("should throw when appending to a text", () { 65 // test("should throw when appending to a text", () {
69 // var parent = new Text(); 66 // var parent = new Text();
70 // expect(() { 67 // expect(() {
71 // parent.replaceChild(document.createElement("div"), null); 68 // parent.replaceChild(document.createElement("div"), null);
72 // }, throws); 69 // }, throws);
73 // }); 70 // });
74 } 71 }
75 </script>
76 </sky>
OLDNEW
« no previous file with comments | « sky/tests/dom/ownerScope.sky ('k') | sky/tests/dom/replaceChild.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698