Skip to content
Browse files

Add tests fro XMLFragment.prototype.clone()

  • Loading branch information...
1 parent 5424f0a commit c544ea034f76f665f79fcf5ab3ea94328bf5e4ea @piroor piroor committed Jul 26, 2012
Showing with 24 additions and 0 deletions.
  1. +24 −0 test/test.coffee
View
24 test/test.coffee
@@ -169,3 +169,27 @@ test9 = builder.begin('test9').text('')
.doc().toString()
assert.strictEqual(xml9, test9)
+# Test the clone() method (not deep clone)
+xml10 = '<test10><nodes><node>1</node></nodes></test10>'
+xml10cloned = '<test10><added>3</added></test10>'
+test10 = builder.begin('test10')
+ .ele('nodes',)
+ .ele('node', '1')
+ .root()
+test10cloned = test10.root().clone()
+test10cloned.ele('added', '3')
+assert.strictEqual(xml10cloned, test10cloned.toString())
+assert.strictEqual(xml10, test10.doc().toString())
+
+# Test the clone() method (deep clone)
+xml11 = '<test11><nodes><node>1</node><node>2</node></nodes></test11>'
+xml11cloned = '<test11><nodes><node>1</node><node>2</node></nodes><added>3</added></test11>'
+test11 = builder.begin('test11')
+ .ele('nodes',)
+ .ele('node', '1').up()
+ .ele('node', '2')
+ .root()
+test11cloned = test11.root().clone(true)
+test11cloned.ele('added', '3')
+assert.strictEqual(xml11cloned, test11cloned.toString())
+assert.strictEqual(xml11, test11.doc().toString())

0 comments on commit c544ea0

Please sign in to comment.
Something went wrong with that request. Please try again.