X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/f4b30e13f370f50a926971df2d23ca423a0c88d8..2687ec6cbbe8101a4faa232c79f5c1321dcebe6d:/src/smartxml/smartxml.test.js diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index e4e2724..a994f05 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -219,6 +219,21 @@ describe('smartxml', function() { expect(event.meta.oldVal).to.equal('value1'); }); }); + + describe('Searching for the last child text node', function() { + [ + '
xxx
last
', + '
last
', + '
xxx
last
' + ].forEach(function(xml, i) { + var example = 'example ' + i; + it('returns last child text node ' + example + ')', function() { + var doc = getDocumentFromXML(xml), + lastTextNode = doc.root.getLastTextNode(); + expect(lastTextNode.getText()).to.equal('last', example); + }); + }); + }); }); describe('Basic TextNode properties', function() { @@ -1679,6 +1694,29 @@ describe('smartxml', function() { doc.redo(); expect(doc.root.getAttr('t')).to.equal('1'); }); + it('can perform undo of an operation performed after automatic transaction rollback', function() { + var doc = getDocumentFromXML('
'), + extension = {document: {transformations: { + throwingTransformation: function() { throw new Error(); } + }}}; + + doc.registerExtension(extension); + + doc.throwingTransformation(); + + doc.transaction(function() { + doc.root.setAttr('x', '2'); + }); + + expect(doc.undoStack.length).to.equal(1); + expect(doc.root.getAttr('x')).to.equal('2'); + + doc.undo(); + + expect(doc.undoStack.length).to.equal(0); + expect(doc.root.getAttr('x')).to.be.undefined; + + }); }); });