X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/512fcabb2a882e26649612efb2b91f25cfc02ec3..80415f03b8fabc18238c1f283348270331702d2e:/src/smartxml/smartxml.test.js diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index d997aa7..7fd408e 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -30,6 +30,15 @@ describe('smartxml', function() { var doc = getDocumentFromXML('
'); expect(doc.root.getTagName()).to.equal('div'); }); + + it('can resets its content entirely', function() { + var doc = getDocumentFromXML('
'); + + expect(doc.root.getTagName()).to.equal('div'); + + doc.loadXML('
'); + expect(doc.root.getTagName()).to.equal('header'); + }); }); describe('Basic ElementNode properties', function() { @@ -68,6 +77,19 @@ describe('smartxml', function() { }); describe('Changing node tag', function() { + it('can change tag name', function() { + var doc = getDocumentFromXML('
'), + header = doc.root.contents()[0]; + header.setTag('span'); + expect(header.getTagName()).to.equal('span'); + + // DOM specifies ElementNode tag as a read-only property, so + // changing it in a seamless way is a little bit tricky. For this reason + // the folowing expectations are required, despite the fact that they actually are + // motivated by implemetation detail. + expect(header.parent().sameNode(doc.root)).to.equal(true, 'ensure we stayed in a document'); + }); + it('keeps custom data', function() { var node = elementNodeFromXML('
');