5 ], function(chai, sinon, smartxml) {
9 /* global describe, it, beforeEach */
11 var expect = chai.expect;
14 var getDocumentFromXML = function(xml) {
15 return smartxml.documentFromXML(xml);
18 var elementNodeFromParams = function(params) {
19 return smartxml.elementNodeFromXML('<' + params.tag + '></' + params.tag + '>');
22 var elementNodeFromXML = function(xml) {
23 return smartxml.elementNodeFromXML(xml);
27 describe('smartxml', function() {
29 describe('Basic Document properties', function() {
30 it('exposes its root element', function() {
31 var doc = getDocumentFromXML('<div></div>');
32 expect(doc.root.getTagName()).to.equal('div');
35 it('can resets its content entirely', function() {
36 var doc = getDocumentFromXML('<div></div>');
38 expect(doc.root.getTagName()).to.equal('div');
40 doc.loadXML('<header></header>');
41 expect(doc.root.getTagName()).to.equal('header');
44 it('knows if it contains an ElementNode in its tree', function() {
45 var doc = getDocumentFromXML('<root><a></a>text</root>'),
47 a = root.contents()[0],
48 text = root.contents()[1];
50 expect(doc.containsNode(root)).to.equal(true, 'contains its root');
51 expect(doc.containsNode(a)).to.equal(true, 'contains Element Node');
52 expect(doc.containsNode(text)).to.equal(true, 'contains Text Node');
55 it('creates text nodes', function() {
56 var doc = getDocumentFromXML('<div></div>'),
57 emptyTextNode = doc.createDocumentNode({text:''}),
58 nonEmptyTextNode = doc.createDocumentNode({text: 'alice'});
59 expect(emptyTextNode.getText()).to.equal('', 'empty ok');
60 expect(nonEmptyTextNode.getText()).to.equal('alice', 'non empty ok');
64 describe('DocumentNode', function() {
65 it('can be cloned', function() {
66 var doc = getDocumentFromXML('<div>Alice</div>'),
67 text = doc.root.contents()[0],
70 [doc.root, text].forEach(function(node) {
71 suffix = ' (' + (node.nodeType === Node.TEXT_NODE ? 'text' : 'element') + ')';
73 expect(doc.containsNode(clone)).to.equal(false, 'clone is not contained in a document' + suffix);
74 expect(node.sameNode(clone)).to.equal(false, 'clone is not same node as its originator' + suffix);
75 expect(node.nativeNode.isEqualNode(clone.nativeNode)).to.equal(true, 'clone is identical as its originator' + suffix);
80 describe('Basic ElementNode properties', function() {
81 it('exposes node contents', function() {
82 var node = elementNodeFromXML('<node>Some<node>text</node>is here</node>'),
83 contents = node.contents();
85 expect(contents).to.have.length(3);
86 expect(contents[0].nodeType).to.equal(Node.TEXT_NODE, 'text node 1');
87 expect(contents[1].nodeType).to.equal(Node.ELEMENT_NODE, 'element node 1');
88 expect(contents[2].nodeType).to.equal(Node.TEXT_NODE, 'text node 2');
91 describe('Storing custom data', function() {
94 beforeEach(function() {
95 node = elementNodeFromXML('<div></div>');
98 it('can append single value', function() {
99 node.setData('key', 'value');
100 expect(node.getData('key')).to.equal('value');
103 it('can overwrite the whole data', function() {
104 node.setData('key1', 'value1');
105 node.setData({key2: 'value2'});
106 expect(node.getData('key2')).to.equal('value2');
109 it('can fetch the whole data at once', function() {
110 node.setData({key1: 'value1', key2: 'value2'});
111 expect(node.getData()).to.eql({key1: 'value1', key2: 'value2'});
115 describe('Changing node tag', function() {
117 it('can change tag name', function() {
118 var node = elementNodeFromXML('<div></div>');
120 expect(node.getTagName()).to.equal('span');
123 it('emits nodeTagChange event', function() {
124 var node = elementNodeFromXML('<div></div>'),
127 node.document.on('change', spy);
129 var event = spy.args[0][0];
131 expect(event.type).to.equal('nodeTagChange');
132 expect(event.meta.node.sameNode(node)).to.be.true;
133 expect(event.meta.oldTagName).to.equal('div');
136 describe('Implementation specific expectations', function() {
137 // DOM specifies ElementNode tag as a read-only property, so
138 // changing it in a seamless way is a little bit tricky. For this reason
139 // the folowing expectations are required, despite the fact that they actually are
140 // motivated by implemetation details.
142 it('keeps node in the document', function() {
143 var doc = getDocumentFromXML('<div><header></header></div>'),
144 header = doc.root.contents()[0];
145 header.setTag('span');
146 expect(header.parent().sameNode(doc.root)).to.be.true;
148 it('keeps custom data', function() {
149 var node = elementNodeFromXML('<div></div>');
151 node.setData('key', 'value');
152 node.setTag('header');
154 expect(node.getTagName()).to.equal('header');
155 expect(node.getData()).to.eql({key: 'value'});
158 it('can change document root tag name', function() {
159 var doc = getDocumentFromXML('<div></div>');
160 doc.root.setTag('span');
161 expect(doc.root.getTagName()).to.equal('span');
164 it('keeps contents', function() {
165 var node = elementNodeFromXML('<div><div></div></div>');
166 node.setTag('header');
167 expect(node.contents()).to.have.length(1);
171 describe('Setting node attributes', function() {
172 it('can set node attribute', function() {
173 var node = elementNodeFromXML('<div></div>');
175 node.setAttr('key', 'value');
176 expect(node.getAttr('key')).to.equal('value');
178 it('emits nodeAttrChange event', function() {
179 var node = elementNodeFromXML('<div key="value1"></div>'),
182 node.document.on('change', spy);
183 node.setAttr('key', 'value2');
184 var event = spy.args[0][0];
186 expect(event.type).to.equal('nodeAttrChange');
187 expect(event.meta.node.sameNode(node)).to.be.true;
188 expect(event.meta.attr).to.equal('key');
189 expect(event.meta.oldVal).to.equal('value1');
196 describe('Basic TextNode properties', function() {
197 it('can have its text set', function() {
198 var node = elementNodeFromXML('<div>Alice</div>'),
199 textNode = node.contents()[0];
201 textNode.setText('Cat');
202 expect(textNode.getText()).to.equal('Cat');
205 it('emits nodeTextChange', function() {
206 var node = elementNodeFromXML('<div>Alice</div>'),
207 textNode = node.contents()[0],
210 textNode.document.on('change', spy);
211 textNode.setText('Cat');
213 var event = spy.args[0][0];
214 expect(event.type).to.equal('nodeTextChange');
217 it('puts NodeElement after itself', function() {
218 var node = elementNodeFromXML('<div>Alice</div>'),
219 textNode = node.contents()[0],
220 returned = textNode.after({tagName:'div'});
221 expect(returned.sameNode(node.contents()[1])).to.be.true;
224 it('puts NodeElement before itself', function() {
225 var node = elementNodeFromXML('<div>Alice</div>'),
226 textNode = node.contents()[0],
227 returned = textNode.before({tagName:'div'});
228 expect(returned.sameNode(node.contents()[0])).to.be.true;
231 describe('Wrapping TextNode contents', function() {
233 it('wraps DocumentTextElement', function() {
234 var node = elementNodeFromXML('<section>Alice</section>'),
235 textNode = node.contents()[0];
237 var returned = textNode.wrapWith({tagName: 'header'}),
238 parent = textNode.parent(),
239 parent2 = node.contents()[0];
241 expect(returned.sameNode(parent)).to.be.equal(true, 'wrapper is a parent');
242 expect(returned.sameNode(parent2)).to.be.equal(true, 'wrapper has a correct parent');
243 expect(returned.getTagName()).to.equal('header');
246 describe('wrapping part of DocumentTextElement', function() {
247 [{start: 5, end: 12}, {start: 12, end: 5}].forEach(function(offsets) {
248 it('wraps in the middle ' + offsets.start + '/' + offsets.end, function() {
249 var node = elementNodeFromXML('<section>Alice has a cat</section>'),
250 textNode = node.contents()[0];
252 var returned = textNode.wrapWith({tagName: 'header', attrs: {'attr1': 'value1'}, start: offsets.start, end: offsets.end}),
253 contents = node.contents();
255 expect(contents.length).to.equal(3);
257 expect(contents[0].nodeType).to.be.equal(Node.TEXT_NODE, 'first node is text node');
258 expect(contents[0].getText()).to.equal('Alice');
260 expect(contents[1].sameNode(returned)).to.be.true;
261 expect(returned.getTagName()).to.equal('header');
262 expect(returned.getAttr('attr1')).to.equal('value1');
263 expect(contents[1].contents().length).to.equal(1, 'wrapper has one node inside');
264 expect(contents[1].contents()[0].getText()).to.equal(' has a ');
266 expect(contents[2].nodeType).to.be.equal(Node.TEXT_NODE, 'third node is text node');
267 expect(contents[2].getText()).to.equal('cat');
271 it('wraps whole text inside DocumentTextElement if offsets span entire content', function() {
272 var node = elementNodeFromXML('<section>Alice has a cat</section>'),
273 textNode = node.contents()[0];
275 textNode.wrapWith({tagName: 'header', start: 0, end: 15});
277 var contents = node.contents();
278 expect(contents.length).to.equal(1);
279 expect(contents[0].getTagName()).to.equal('header');
280 expect(contents[0].contents()[0].getText()).to.equal('Alice has a cat');
287 describe('Manipulations', function() {
289 it('merges adjacent text nodes resulting from detaching an element node in between', function() {
290 var doc = getDocumentFromXML('<div>Alice <span>has</span>a cat</div>'),
291 span = doc.root.contents()[1];
295 var rootContents = doc.root.contents();
296 expect(rootContents).to.have.length(1, 'one child left');
297 expect(rootContents[0].getText()).to.equal('Alice a cat');
300 it('appends element node to another element node', function() {
301 var node1 = elementNodeFromParams({tag: 'div'}),
302 node2 = elementNodeFromParams({tag: 'a'}),
303 node3 = elementNodeFromParams({tag: 'p'});
306 expect(node1.contents()[0].sameNode(node2)).to.be.true;
307 expect(node1.contents()[1].sameNode(node3)).to.be.true;
310 it('prepends element node to another element node', function() {
311 var node1 = elementNodeFromParams({tag: 'div'}),
312 node2 = elementNodeFromParams({tag: 'a'}),
313 node3 = elementNodeFromParams({tag: 'p'});
314 node1.prepend(node2);
315 node1.prepend(node3);
316 expect(node1.contents()[0].sameNode(node3)).to.be.true;
317 expect(node1.contents()[1].sameNode(node2)).to.be.true;
320 it('wraps element node with another element node', function() {
321 var node = elementNodeFromXML('<div></div>'),
322 wrapper = elementNodeFromXML('<wrapper></wrapper>');
324 node.wrapWith(wrapper);
325 expect(node.parent().sameNode(wrapper)).to.be.true;
328 it('unwraps element node contents', function() {
329 var node = elementNodeFromXML('<div>Alice <div>has <span>propably</span> a cat</div>!</div>'),
330 outerDiv = node.contents()[1];
332 outerDiv.unwrapContent();
334 expect(node.contents().length).to.equal(3);
335 expect(node.contents()[0].getText()).to.equal('Alice has ');
336 expect(node.contents()[1].getTagName()).to.equal('span');
337 expect(node.contents()[2].getText()).to.equal(' a cat!');
340 it('unwrap single element node from its parent', function() {
341 var doc = getDocumentFromXML('<div><a><b></b></a></div>'),
343 a = div.contents()[0],
346 var parent = b.unwrap();
348 expect(parent.sameNode(div)).to.equal(true, 'returns new parent');
349 expect(div.contents()).to.have.length(1, 'root contains only one node');
350 expect(div.contents()[0].sameNode(b)).to.equal(true, 'node got unwrapped');
353 it('unwrap single text node from its parent', function() {
354 var doc = getDocumentFromXML('<div>Some <span>text</span>!</div>'),
356 span = div.contents()[1],
357 text = span.contents()[0];
359 var parent = text.unwrap();
361 expect(parent.sameNode(div)).to.equal(true, 'returns new parent');
362 expect(div.contents()).to.have.length(1, 'root contains only one node');
363 expect(div.contents()[0].getText()).to.equal('Some text!');
366 describe('Wrapping text', function() {
367 it('wraps text spanning multiple sibling TextNodes', function() {
368 var section = elementNodeFromXML('<section>Alice has a <span>small</span> cat</section>'),
369 wrapper = section.wrapText({
370 _with: {tagName: 'span', attrs: {'attr1': 'value1'}},
376 expect(section.contents().length).to.equal(2);
377 expect(section.contents()[0].nodeType).to.equal(Node.TEXT_NODE);
378 expect(section.contents()[0].getText()).to.equal('Alice ');
380 var wrapper2 = section.contents()[1];
381 expect(wrapper2.sameNode(wrapper)).to.be.true;
382 expect(wrapper.getTagName()).to.equal('span');
384 var wrapperContents = wrapper.contents();
385 expect(wrapperContents.length).to.equal(3);
386 expect(wrapperContents[0].getText()).to.equal('has a ');
388 expect(wrapperContents[1].nodeType).to.equal(Node.ELEMENT_NODE);
389 expect(wrapperContents[1].contents().length).to.equal(1);
390 expect(wrapperContents[1].contents()[0].getText()).to.equal('small');
394 describe('Wrapping Nodes', function() {
395 it('wraps multiple sibling nodes', function() {
396 var section = elementNodeFromXML('<section>Alice<div>has</div><div>a cat</div></section>'),
397 aliceText = section.contents()[0],
398 firstDiv = section.contents()[1],
399 lastDiv = section.contents()[section.contents().length -1];
401 var returned = section.document.wrapNodes({
404 _with: {tagName: 'header'}
407 var sectionContentss = section.contents(),
408 header = sectionContentss[0],
409 headerContents = header.contents();
411 expect(sectionContentss).to.have.length(1);
412 expect(header.sameNode(returned)).to.equal(true, 'wrapper returned');
413 expect(header.parent().sameNode(section)).to.be.true;
414 expect(headerContents).to.have.length(3);
415 expect(headerContents[0].sameNode(aliceText)).to.equal(true, 'first node wrapped');
416 expect(headerContents[1].sameNode(firstDiv)).to.equal(true, 'second node wrapped');
417 expect(headerContents[2].sameNode(lastDiv)).to.equal(true, 'third node wrapped');
420 it('wraps multiple sibling Elements - middle case', function() {
421 var section = elementNodeFromXML('<section><div></div><div></div><div></div><div></div></section>'),
422 div2 = section.contents()[1],
423 div3 = section.contents()[2];
425 section.document.wrapNodes({
428 _with: {tagName: 'header'}
431 var sectionContentss = section.contents(),
432 header = sectionContentss[1],
433 headerChildren = header.contents();
435 expect(sectionContentss).to.have.length(3);
436 expect(headerChildren).to.have.length(2);
437 expect(headerChildren[0].sameNode(div2)).to.equal(true, 'first node wrapped');
438 expect(headerChildren[1].sameNode(div3)).to.equal(true, 'second node wrapped');
444 describe('Splitting text', function() {
446 it('splits TextNode\'s parent into two ElementNodes', function() {
447 var doc = getDocumentFromXML('<section><header>Some header</header></section>'),
449 text = section.contents()[0].contents()[0];
451 var returnedValue = text.split({offset: 5});
452 expect(section.contents().length).to.equal(2, 'section has two children');
454 var header1 = section.contents()[0];
455 var header2 = section.contents()[1];
457 expect(header1.getTagName()).to.equal('header', 'first section child ok');
458 expect(header1.contents().length).to.equal(1, 'first header has one child');
459 expect(header1.contents()[0].getText()).to.equal('Some ', 'first header has correct content');
460 expect(header2.getTagName()).to.equal('header', 'second section child ok');
461 expect(header2.contents().length).to.equal(1, 'second header has one child');
462 expect(header2.contents()[0].getText()).to.equal('header', 'second header has correct content');
464 expect(returnedValue.first.sameNode(header1)).to.equal(true, 'first node returned');
465 expect(returnedValue.second.sameNode(header2)).to.equal(true, 'second node returned');
468 it('leaves empty copy of ElementNode if splitting at the very beginning', function() {
469 var doc = getDocumentFromXML('<section><header>Some header</header></section>'),
471 text = section.contents()[0].contents()[0];
473 text.split({offset: 0});
475 var header1 = section.contents()[0];
476 var header2 = section.contents()[1];
478 expect(header1.contents().length).to.equal(0);
479 expect(header2.contents()[0].getText()).to.equal('Some header');
482 it('leaves empty copy of ElementNode if splitting at the very end', function() {
483 var doc = getDocumentFromXML('<section><header>Some header</header></section>'),
485 text = section.contents()[0].contents()[0];
487 text.split({offset: 11});
489 var header1 = section.contents()[0];
490 var header2 = section.contents()[1];
492 expect(header1.contents()[0].getText()).to.equal('Some header');
493 expect(header2.contents().length).to.equal(0);
496 it('keeps TextNodes\'s parent\'s children elements intact', function() {
497 var doc = getDocumentFromXML('<section><header>A <span>fancy</span> and <span>nice</span> header</header></section>'),
499 header = section.contents()[0],
500 textAnd = header.contents()[2];
502 textAnd.split({offset: 2});
504 var sectionContents = section.contents();
505 expect(sectionContents.length).to.equal(2, 'Section has two children');
506 expect(sectionContents[0].getTagName()).to.equal('header', 'First section node is a header');
507 expect(sectionContents[1].getTagName()).to.equal('header', 'Second section node is a header');
509 var firstHeaderContents = sectionContents[0].contents();
510 expect(firstHeaderContents.length).to.equal(3, 'First header has three children');
511 expect(firstHeaderContents[0].getText()).to.equal('A ', 'First header starts with a text');
512 expect(firstHeaderContents[1].getTagName()).to.equal('span', 'First header has span in the middle');
513 expect(firstHeaderContents[2].getText()).to.equal(' a', 'First header ends with text');
515 var secondHeaderContents = sectionContents[1].contents();
516 expect(secondHeaderContents.length).to.equal(3, 'Second header has three children');
517 expect(secondHeaderContents[0].getText()).to.equal('nd ', 'Second header starts with text');
518 expect(secondHeaderContents[1].getTagName()).to.equal('span', 'Second header has span in the middle');
519 expect(secondHeaderContents[2].getText()).to.equal(' header', 'Second header ends with text');
523 describe('Events', function() {
524 it('emits nodeDetached event on node detach', function() {
525 var node = elementNodeFromXML('<div><div></div></div>'),
526 innerNode = node.contents()[0],
528 node.document.on('change', spy);
530 var detached = innerNode.detach(),
531 event = spy.args[0][0];
533 expect(event.type).to.equal('nodeDetached');
534 expect(event.meta.node.sameNode(detached, 'detached node in event meta'));
535 expect(event.meta.parent.sameNode(node), 'original parent node in event meta');
538 it('emits nodeAdded event when appending new node', function() {
539 var node = elementNodeFromXML('<div></div>'),
541 node.document.on('change', spy);
543 var appended = node.append({tagName:'div'}),
544 event = spy.args[0][0];
545 expect(event.type).to.equal('nodeAdded');
546 expect(event.meta.node.sameNode(appended)).to.be.true;
549 it('emits nodeMoved when appending aready existing node', function() {
550 var node = elementNodeFromXML('<div><a></a><b></b></div>'),
551 a = node.contents()[0],
552 b = node.contents()[1],
554 node.document.on('change', spy);
556 var appended = a.append(b),
557 event = spy.args[0][0];
559 expect(spy.callCount).to.equal(1);
560 expect(event.type).to.equal('nodeMoved');
561 expect(event.meta.node.sameNode(appended)).to.be.true;
564 it('emits nodeAdded event when prepending new node', function() {
565 var node = elementNodeFromXML('<div></div>'),
567 node.document.on('change', spy);
569 var prepended = node.prepend({tagName:'div'}),
570 event = spy.args[0][0];
571 expect(event.type).to.equal('nodeAdded');
572 expect(event.meta.node.sameNode(prepended)).to.be.true;
575 it('emits nodeMoved when prepending aready existing node', function() {
576 var node = elementNodeFromXML('<div><a></a><b></b></div>'),
577 a = node.contents()[0],
578 b = node.contents()[1],
580 node.document.on('change', spy);
582 var prepended = a.prepend(b),
583 event = spy.args[0][0];
584 expect(spy.callCount).to.equal(1);
585 expect(event.type).to.equal('nodeMoved');
586 expect(event.meta.node.sameNode(prepended)).to.be.true;
589 it('emits nodeAdded event when inserting node after another', function() {
590 var node = elementNodeFromXML('<div><a></a></div>').contents()[0],
592 node.document.on('change', spy);
594 var inserted = node.after({tagName:'div'}),
595 event = spy.args[0][0];
596 expect(event.type).to.equal('nodeAdded');
597 expect(event.meta.node.sameNode(inserted)).to.be.true;
600 it('emits nodeMoved when inserting aready existing node after another', function() {
601 var node = elementNodeFromXML('<div><a></a><b></b></div>'),
602 a = node.contents()[0],
603 b = node.contents()[1],
605 node.document.on('change', spy);
606 var inserted = b.after(a),
607 event = spy.args[0][0];
609 expect(spy.callCount).to.equal(1);
610 expect(event.type).to.equal('nodeMoved');
611 expect(event.meta.node.sameNode(inserted)).to.be.true;
614 it('emits nodeAdded event when inserting node before another', function() {
615 var node = elementNodeFromXML('<div><a></a></div>').contents()[0],
617 node.document.on('change', spy);
619 var inserted = node.before({tagName:'div'}),
620 event = spy.args[0][0];
621 expect(event.type).to.equal('nodeAdded');
622 expect(event.meta.node.sameNode(inserted)).to.be.true;
625 it('emits nodeAdded when inserting aready existing node before another', function() {
626 var node = elementNodeFromXML('<div><a></a><b></b></div>'),
627 a = node.contents()[0],
628 b = node.contents()[1],
630 node.document.on('change', spy);
631 var inserted = a.before(b),
632 event = spy.args[0][0];
634 expect(spy.callCount).to.equal(1);
635 expect(event.type).to.equal('nodeMoved');
636 expect(event.meta.node.sameNode(inserted)).to.be.true;
640 describe('Traversing', function() {
641 describe('Basic', function() {
642 it('can access node parent', function() {
643 var doc = getDocumentFromXML('<a><b></b></a>'),
647 expect(a.parent()).to.equal(null, 'parent of a root is null');
648 expect(b.parent().sameNode(a)).to.be.true;
650 it('can access node parents', function() {
651 var doc = getDocumentFromXML('<a><b><c></c></b></a>'),
656 var parents = c.parents();
657 expect(parents).to.eql([b,a]);
661 describe('finding sibling parents of two elements', function() {
662 it('returns elements themself if they have direct common parent', function() {
663 var doc = getDocumentFromXML('<section><div><div>A</div><div>B</div></div></section>'),
664 wrappingDiv = doc.root.contents()[0],
665 divA = wrappingDiv.contents()[0],
666 divB = wrappingDiv.contents()[1];
668 var siblingParents = doc.getSiblingParents({node1: divA, node2: divB});
670 expect(siblingParents.node1.sameNode(divA)).to.equal(true, 'divA');
671 expect(siblingParents.node2.sameNode(divB)).to.equal(true, 'divB');
674 it('returns sibling parents - example 1', function() {
675 var doc = getDocumentFromXML('<section>Alice <span>has a cat</span></section>'),
676 aliceText = doc.root.contents()[0],
677 span = doc.root.contents()[1],
678 spanText = span.contents()[0];
680 var siblingParents = doc.getSiblingParents({node1: aliceText, node2: spanText});
682 expect(siblingParents.node1.sameNode(aliceText)).to.equal(true, 'aliceText');
683 expect(siblingParents.node2.sameNode(span)).to.equal(true, 'span');
688 describe('Serializing document to WLXML', function() {
689 it('keeps document intact when no changes have been made', function() {
690 var xmlIn = '<section>Alice<div>has</div>a <span class="uri" meta-uri="http://cat.com">cat</span>!</section>',
691 doc = getDocumentFromXML(xmlIn),
692 xmlOut = doc.toXML();
694 var parser = new DOMParser(),
695 input = parser.parseFromString(xmlIn, 'application/xml').childNodes[0],
696 output = parser.parseFromString(xmlOut, 'application/xml').childNodes[0];
698 expect(input.isEqualNode(output)).to.be.true;
701 it('keeps entities intact', function() {
702 var xmlIn = '<section>< ></section>',
703 doc = getDocumentFromXML(xmlIn),
704 xmlOut = doc.toXML();
705 expect(xmlOut).to.equal(xmlIn);
707 it('keeps entities intact when they form html/xml', function() {
708 var xmlIn = '<section><abc></section>',
709 doc = getDocumentFromXML(xmlIn),
710 xmlOut = doc.toXML();
711 expect(xmlOut).to.equal(xmlIn);