X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/ca1c01b10805014a2f1c24c6f055cd77fc66af01..eda3b8f3b50cc6f2a7d770c8cdd0e35010062931:/modules/documentCanvas/canvas/canvas.test3.js diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 95698d0..c969ba9 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -403,6 +403,38 @@ describe('Canvas', function() { expect(returned.sameNode(sectionChildren[1])); expect(rhsText.getText()).to.equal(' has a cat'); }); + + it('treats dividing DocumentTextElement at the very end as appending after it', function() { + var c = canvas.fromXML('
Alice has a cat
'), + section = c.doc(), + text = section.children()[0]; + + var returned = text.divide({tag: 'aside', klass: 'footnote', offset: 15}), + sectionChildren = section.children(), + textElement = sectionChildren[0], + nodeElement = sectionChildren[1]; + + expect(sectionChildren.length).to.equal(2); + expect(textElement.getText()).to.equal('Alice has a cat'); + expect(returned.sameNode(nodeElement)).to.be.true; + expect(nodeElement.getWlxmlTag()).to.equal('aside'); + }); + + it('treats dividing DocumentTextElement at the very beginning as appending before it', function() { + var c = canvas.fromXML('
Alice has a cat
'), + section = c.doc(), + text = section.children()[0]; + + var returned = text.divide({tag: 'aside', klass: 'footnote', offset: 0}), + sectionChildren = section.children(), + nodeElement = sectionChildren[0], + textElement = sectionChildren[1]; + + expect(sectionChildren.length).to.equal(2); + expect(textElement.getText()).to.equal('Alice has a cat'); + expect(returned.sameNode(nodeElement)).to.be.true; + expect(nodeElement.getWlxmlTag()).to.equal('aside'); + }); }); describe('Splitting text', function() {