X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/7427515e04e110e91793887b873f5853751c271a..9e5d2dd07732d54da694d199c551b1818eeee3da:/src/smartxml/smartxml.test.js?ds=sidebyside
diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js
index cc2b3cf..fb420db 100644
--- a/src/smartxml/smartxml.test.js
+++ b/src/smartxml/smartxml.test.js
@@ -220,6 +220,7 @@ describe('smartxml', function() {
expect(node.contents()).to.have.length(1);
});
});
+ });
describe('Setting node attributes', function() {
it('can set node attribute', function() {
@@ -242,8 +243,6 @@ describe('smartxml', function() {
expect(event.meta.oldVal).to.equal('value1');
});
});
-
- });
});
describe('Basic TextNode properties', function() {
@@ -1650,6 +1649,32 @@ describe('smartxml', function() {
var transaction = doc.undoStack[0];
expect(transaction.metadata).to.equal(metadata);
});
+
+ it('can be rolled back', function() {
+ var doc = getDocumentFromXML('');
+
+ doc.startTransaction();
+ doc.root.append({tagName: 'div'});
+ doc.rollbackTransaction();
+
+ expect(doc.undoStack.length).to.equal(0, 'nothing to undo');
+ expect(doc.root.contents().length).to.equal(0);
+ });
+
+ it('rollbacks and calls error handleor if error gets thrown', function() {
+ var doc = getDocumentFromXML(''),
+ err = new Error(),
+ spy = sinon.spy();
+
+ doc.transaction(function() {
+ doc.root.append({tagName: 'div'});
+ throw err;
+ }, {error: spy});
+
+ expect(spy.args[0][0]).to.equal(err);
+ expect(doc.root.contents().length).to.equal(0);
+ expect(doc.undoStack.length).to.equal(0);
+ });
});
describe('Regression tests', function() {