X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/421c624a25e602a3d3bb72bd6c01cbb04cbf7d11..c2f61b78499f7c1f4f722ef4a4b5514c95598505:/modules/documentCanvas/canvas/canvas.test3.js diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 3778698..705ef2c 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -267,6 +267,32 @@ describe('Canvas', function() { expect(c.doc().children()[2].getText()).to.equal(' cat'); }); }); + + describe('getting vertically first text element', function() { + it('returns the first child if it\'s text element, ignores metadata', function() { + var c = canvas.fromXML('
authorAlice
has
a cat
'), + first = c.doc().getVerticallyFirstTextElement(); + + expect(first.sameNode(c.doc().children()[1])).to.be.true; + }); + + it('looks recursively inside node elements if they precede text element', function() { + var c = canvas.fromXML('\ +
\ +
\ +
\ + Alice\ +
\ +
\ + Some text\ +
'), + textAlice = c.doc().children()[0].children()[0].children()[0], + first = c.doc().getVerticallyFirstTextElement(); + + expect(textAlice).to.be.instanceOf(documentElement.DocumentTextElement); + expect(first.sameNode(textAlice)).to.be.true; + }); + }); }); describe('manipulation api', function() {