+ describe('replacing node with another one', function() {
+ it('replaces node with another one', function() {
+ var doc = getDocumentFromXML('<div><a></a></div>'),
+ a = doc.root.contents()[0];
+
+ var c = a.replaceWith({tagName: 'b', attrs: {b:'1'}});
+
+ expect(doc.root.contents()[0].sameNode(c));
+ expect(c.getTagName()).to.equal('b');
+ expect(c.getAttr('b')).to.equal('1');
+ });
+ it('can replace document root', function() {
+ var doc = getDocumentFromXML('<div></div>');
+
+ var header = doc.root.replaceWith({tagName: 'header'});
+
+ expect(doc.root.sameNode(header)).to.be.true;
+ expect(doc.containsNode(header)).to.be.true;
+ });
+ });
+