X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/0054f55492949c1b2b473a80d7fc170931b0a857..72006ca5628befdc32bb1cd31002f22c4a7c8bca:/modules/documentCanvas/canvas/canvas.test3.js diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 95f9f60..56f8ee6 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -208,6 +208,18 @@ describe('Canvas', function() { expect(children[1]).to.be.instanceOf(documentElement.DocumentNodeElement); expect(children[1].sameNode(added)).to.be.true; }); + it('can put new DocumentNodeElement before DocumentTextElement', function() { + var c = canvas.fromXML('
Alice
'), + text = c.doc().children()[0], + added = text.before({tag: 'p'}), + children = c.doc().children(); + + expect(children.length).to.equal(2); + expect(children[0]).to.be.instanceOf(documentElement.DocumentNodeElement); + expect(children[0].sameNode(added)).to.be.true; + expect(children[1]).to.be.instanceOf(documentElement.DocumentTextElement); + expect(children[1].getText()).to.equal('Alice'); + }); }); describe('Splitting text', function() { @@ -338,6 +350,29 @@ describe('Canvas', function() { }); }); + describe('Lists api', function() { + it('allows creation of a list from existing sibling DocumentElements', function() { + var c = canvas.fromXML('\ +
\ + Alice\ +
has
\ + a\ +
cat
\ +
'), + section = c.doc(), + textAlice = section.children()[0], + divCat = section.children()[3] + + c.list.create({element1: textAlice, element2: divCat}); + + expect(section.children().length).to.equal(1, 'section has one child element'); + + var list = section.children()[0]; + expect(list.is('list')).to.equal(true, 'section\'s only child is a list'); + expect(list.children().length).to.equal(4, 'list contains four elements'); + }); + }); + }); });