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

Unified Diff: tests/html/node_test.dart

Issue 12374060: Adding Node.insertAllBefore (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_Node.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/node_test.dart
diff --git a/tests/html/node_test.dart b/tests/html/node_test.dart
index fe31ed764c2de4f5f86faa36043596662a55dfd0..c8da7aa7ac23fe7bde5f8ef30862187d6b2cf0d0 100644
--- a/tests/html/node_test.dart
+++ b/tests/html/node_test.dart
@@ -25,33 +25,69 @@ main() {
var isInputElement =
predicate((x) => x is InputElement, 'is an InputElement');
- test('replaceWith', () {
- final node = makeNodeWithChildren();
- final subnode = node.nodes[1];
- final out = subnode.replaceWith(new Text('Bar'));
- expect(out, equals(subnode), reason: '#replaceWith should be chainable');
- expect(node.nodes.length, 3);
- expect(node.nodes[0], isText);
- expect(node.nodes[0].text, 'Foo');
- expect(node.nodes[1], isText);
- expect(node.nodes[1].text, 'Bar');
- expect(node.nodes[2], isComment);
- });
+ group('functional', () {
+ test('replaceWith', () {
+ final node = makeNodeWithChildren();
+ final subnode = node.nodes[1];
+ final out = subnode.replaceWith(new Text('Bar'));
+ expect(out, equals(subnode), reason: '#replaceWith should be chainable');
+ expect(node.nodes.length, 3);
+ expect(node.nodes[0], isText);
+ expect(node.nodes[0].text, 'Foo');
+ expect(node.nodes[1], isText);
+ expect(node.nodes[1].text, 'Bar');
+ expect(node.nodes[2], isComment);
+ });
- test('remove', () {
- final node = makeNodeWithChildren();
- final subnode = node.nodes[1];
- subnode.remove();
- expect(node.nodes.length, 2);
- expect(node.nodes[0], isText);
- expect(node.nodes[1], isComment);
- });
+ test('remove', () {
+ final node = makeNodeWithChildren();
+ final subnode = node.nodes[1];
+ subnode.remove();
+ expect(node.nodes.length, 2);
+ expect(node.nodes[0], isText);
+ expect(node.nodes[1], isComment);
+ });
+
+ test('contains', () {
+ final Node node = new Element.html("<div>Foo<span>Bar</span></div>");
+ expect(node.contains(node.nodes.first), isTrue);
+ expect(node.contains(node.nodes[1].nodes.first), isTrue);
+ expect(node.contains(new Text('Foo')), isFalse);
+ });
- test('contains', () {
- final Node node = new Element.html("<div>Foo<span>Bar</span></div>");
- expect(node.contains(node.nodes.first), isTrue);
- expect(node.contains(node.nodes[1].nodes.first), isTrue);
- expect(node.contains(new Text('Foo')), isFalse);
+ test('insertAllBefore', () {
+ var node = makeNodeWithChildren();
+ var b = new DivElement();
+ b.nodes.addAll([
+ new HRElement(),
+ new ImageElement(),
+ new InputElement()
+ ]);
+ node.insertAllBefore(b.nodes, node.nodes[1]);
+ expect(node.nodes[0], isText);
+ expect(node.nodes[1], isHRElement);
+ expect(node.nodes[2], isImageElement);
+ expect(node.nodes[3], isInputElement);
+ expect(node.nodes[4], isBRElement);
+ expect(node.nodes[5], isComment);
+
+ var nodes = [
+ new HRElement(),
+ new ImageElement(),
+ new InputElement()
+ ];
+ node.insertAllBefore(nodes, node.nodes[5]);
+
+ expect(node.nodes[0], isText);
+ expect(node.nodes[1], isHRElement);
+ expect(node.nodes[2], isImageElement);
+ expect(node.nodes[3], isInputElement);
+ expect(node.nodes[4], isBRElement);
+ expect(node.nodes[5], isHRElement);
+ expect(node.nodes[6], isImageElement);
+ expect(node.nodes[7], isInputElement);
+ expect(node.nodes[8], isComment);
+ });
});
group('nodes', () {
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_Node.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698