X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/b5d516652ee4cc58a8a0636074456b344126f7d7..8a17c686a21178f73ea93a9d7f2c6ee3bf90aa72:/src/smartxml/smartxml.test.js diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index 0883ba7..e6f0baa 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -1139,6 +1139,7 @@ describe('smartxml', function() { var sampleMethod = function(val) { this._$.attr('x', val); + this.triggerChangeEvent(); }; var transformations = { @@ -1235,10 +1236,12 @@ describe('smartxml', function() { doc.registerExtension({elementNode: {transformations: { nested: function(v) { this._$.attr('innerAttr', v); + this.triggerChangeEvent(); }, outer: function(v) { this.nested(v); this._$.attr('outerAttr', v); + this.triggerChangeEvent(); } }}}); @@ -1270,6 +1273,20 @@ describe('smartxml', function() { }); + it('ignores transformation if document didn\'t emit change event', function() { + var doc = getDocumentFromXML('
'); + + doc.registerExtension({elementNode: {transformations: { + test: function() { + // empty + } + }}}); + + doc.root.test(); + expect(doc.undoStack.length).to.equal(0); + + }); + describe('Transactions', function() { it('allows to undo/redo series of transformations at once', function() { var doc = getDocumentFromXML('
'); @@ -1314,14 +1331,17 @@ describe('smartxml', function() { elementNode: {transformations: { unaware: function(v) { this.setAttr('unware', v); + this.triggerChangeEvent(); }, smart: { impl: function(t, v) { t.oldVal = this.getAttr('smart'); this.setAttr('smart', v); + this.triggerChangeEvent(); }, undo: function(t) { this.setAttr('smart', t.oldVal); + this.triggerChangeEvent(); } } }}