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

Unified Diff: client/tests/client/html/NodeTests.dart

Issue 9295002: Add some more tests for Element and Node. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/tests/client/html/ElementTests.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/client/html/NodeTests.dart
diff --git a/client/tests/client/html/NodeTests.dart b/client/tests/client/html/NodeTests.dart
index 3ed00b65e9549a777a637dc3029f2c2225b9eb84..23ef95ea30486d218e6087f4af7f53ecd3af1e3c 100644
--- a/client/tests/client/html/NodeTests.dart
+++ b/client/tests/client/html/NodeTests.dart
@@ -8,6 +8,36 @@ Node makeNodeWithChildren() =>
new Element.html("<div>Foo<br/><!--baz--></div>");
void testNode() {
+ test('replaceWith', () {
+ final node = makeNodeWithChildren();
+ final subnode = node.nodes[1];
+ final out = subnode.replaceWith(new Text('Bar'));
+ Expect.equals(subnode, out, '#replaceWith should be chainable');
+ Expect.equals(3, node.nodes.length);
+ Expect.isTrue(node.nodes[0] is Text);
+ Expect.equals('Foo', node.nodes[0].text);
+ Expect.isTrue(node.nodes[1] is Text);
+ Expect.equals('Bar', node.nodes[1].text);
+ Expect.isTrue(node.nodes[2] is Comment);
+ });
+
+ test('remove', () {
+ final node = makeNodeWithChildren();
+ final subnode = node.nodes[1];
+ final out = subnode.remove();
+ Expect.equals(subnode, out, '#remove should be chainable');
+ Expect.equals(2, node.nodes.length);
+ Expect.isTrue(node.nodes[0] is Text);
+ Expect.isTrue(node.nodes[1] is Comment);
+ });
+
+ test('contains', () {
+ final Node node = new Element.html("<div>Foo<span>Bar</span></div>");
+ Expect.isTrue(node.contains(node.nodes.first));
+ Expect.isTrue(node.contains(node.nodes[1].nodes.first));
+ Expect.isFalse(node.contains(new Text('Foo')));
+ });
+
group('nodes', () {
test('is a NodeList', () {
Expect.isTrue(makeNodeWithChildren().nodes is NodeList);
« no previous file with comments | « client/tests/client/html/ElementTests.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698