X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/da4ff24177c122a81ecae0e7693ffe2a3276ba1a..7a55de7fa64363dcc4bdcf31dabe2e155018597a:/src/wlxml/wlxml.test.js diff --git a/src/wlxml/wlxml.test.js b/src/wlxml/wlxml.test.js index 7c69bdb..cf8aa74 100644 --- a/src/wlxml/wlxml.test.js +++ b/src/wlxml/wlxml.test.js @@ -185,17 +185,10 @@ describe('WLXMLDocument', function() { }); describe('Extension', function() { - var doc, extension, elementNode, textNode, testClassNode; + var doc, extension, testClassNode; beforeEach(function() { doc = getDocumentFromXML('
Alice
'); - elementNode = doc.root; - textNode = doc.root.contents()[0]; - testClassNode = doc.root.contents('.test_class'); - extension = {}; - - expect(testClassNode.object).to.be.undefined; - }); it('allows adding method to an ElementNode of specific class', function() { @@ -246,6 +239,25 @@ describe('WLXMLDocument', function() { expect(testClassNode.object.testTransformation2().sameNode(testClassNode)).to.equal(true, '2'); }); }); + + describe('Declaring context roots', function() { + it('allows extensions declaring a node as a context root', function() { + var doc = getDocumentFromXML('
'); + doc.registerExtension({wlxmlClass: {a: {methods: { + isContextRoot: function(node) { + return node.getClass() === 'b'; + } + }}}}); + + var divA = doc.root.contents()[0], + divB = divA.contents()[0], + divC = divB.contents()[0]; + + expect(divC.isContextRoot()).to.equal(false, 'c is not a context root'); + expect(divB.isContextRoot()).to.equal(true, 'b is a context root'); + expect(divA.isContextRoot()).to.equal(false, 'a is not a context root'); + }); + }); }); }); \ No newline at end of file