X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/92e3984fd3f6c86739424ef8ee606dc2022af1c5..f4828b331965f0eae8508750aea836d8aa81a8cd:/src/smartxml/smartxml.test.js diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index 8041013..41742d9 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -836,18 +836,15 @@ describe('smartxml', function() { textNode = doc.root.contents()[0]; extension = {}; - expect(function() { - elementNode.testTransformation(); - }).to.throw(Error); - expect(function() { - textNode.testTransformation(); - }).to.throw(Error); - expect(function() { - doc.testTransformation(); - }).to.throw(Error); + expect(elementNode.testTransformation).to.be.undefined; + expect(textNode.testTransformation).to.be.undefined; + expect(doc.testTransformation).to.be.undefined; + expect(doc.testMethod).to.be.undefined; expect(elementNode.testMethod).to.be.undefined; expect(textNode.testMethod).to.be.undefined; + expect(elementNode.elementTestMethod).to.be.undefined; + expect(textNode.textTestMethod).to.be.undefined; }); it('allows adding method to a document', function() { @@ -871,9 +868,23 @@ describe('smartxml', function() { }); it('allows adding method to a DocumentNode instance', function() { - extension = {documentNode: {methods: { - testMethod: function() { return this; } - }}}; + extension = { + documentNode: { + methods: { + testMethod: function() { return this; } + } + }, + textNode: { + methods: { + textTestMethod: function() { return this; } + } + }, + elementNode: { + methods: { + elementTestMethod: function() { return this; } + } + } + }; doc.registerExtension(extension); @@ -883,6 +894,12 @@ describe('smartxml', function() { expect(elementNode.testMethod().sameNode(elementNode)).to.equal(true, 'context is set to a node instance'); expect(textNode.testMethod().sameNode(textNode)).to.equal(true, 'context is set to a node instance'); + + expect(elementNode.elementTestMethod().sameNode(elementNode)).to.be.true; + expect(elementNode.textTestMethod).to.be.undefined; + + expect(textNode.textTestMethod().sameNode(textNode)).to.be.true; + expect(textNode.elementTestMethod).to.be.undefined; }); it('allows adding transformation to a DocumentNode', function() {