X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/6651adb0f9bd9b0c5c83047a3b66f66e1cc7fc57..988d47428991ee70383755b5b4f6d337d3049fee:/modules/documentCanvas/canvas/canvas.test3.js?ds=inline diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 135b0b4..ff7c5c4 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -499,20 +499,24 @@ describe('Canvas', function() {
\
0
\
1
\ +
2
\
\ '), list = c.doc().children()[0], item1 = list.children()[0], - item2 = list.children()[1]; + item2 = list.children()[1], + item3 = list.children()[2]; - c.list.extractItems({element1: item1, element2: item1}); + c.list.extractItems({element1: item1, element2: item2}); var section = c.doc(), - oldItem = section.children()[0], - newList = section.children()[1]; + oldItem1 = section.children()[0], + oldItem2 = section.children()[1], + newList = section.children()[2]; - expect(section.children().length).to.equal(2, 'section has two children'); - expect(oldItem.children()[0].getText()).to.equal('0', 'first item extracted'); + expect(section.children().length).to.equal(3, 'section has three children'); + expect(oldItem1.children()[0].getText()).to.equal('0', 'first item extracted'); + expect(oldItem2.children()[0].getText()).to.equal('1', 'second item extracted'); expect(newList.is('list')).to.equal(true, 'list lies below extracted item'); expect(newList.children().length).to.equal(1, 'list has now one child'); }); @@ -523,20 +527,24 @@ describe('Canvas', function() {
\
0
\
1
\ +
2
\
\ '), list = c.doc().children()[0], item1 = list.children()[0], - item2 = list.children()[1]; + item2 = list.children()[1], + item3 = list.children()[2]; - c.list.extractItems({element1: item2, element2: item2}); + c.list.extractItems({element1: item2, element2: item3}); var section = c.doc(), - oldItem = section.children()[1], + oldItem1 = section.children()[1], + oldItem2 = section.children()[2], newList = section.children()[0]; - expect(section.children().length).to.equal(2, 'section has two children'); - expect(oldItem.children()[0].getText()).to.equal('1', 'first item extracted'); + expect(section.children().length).to.equal(3, 'section has three children'); + expect(oldItem1.children()[0].getText()).to.equal('1', 'first item extracted'); + expect(oldItem2.children()[0].getText()).to.equal('2', 'second item extracted'); expect(newList.is('list')).to.equal(true, 'list lies above extracted item'); expect(newList.children().length).to.equal(1, 'list has now one child'); }); @@ -546,20 +554,23 @@ describe('Canvas', function() {
\
\
some item
\ +
some item 2
\
\
'), list = c.doc().children()[0], - item = list.children()[0]; + item1 = list.children()[0], + item2 = list.children()[1]; - c.list.extractItems({element1: item, element2: item}); + c.list.extractItems({element1: item1, element2: item2}); var section = c.doc(), list1 = section.children()[0], - oldItem1 = section.children()[1], - oldItem2 = section.children()[2], - list2 = section.children()[3]; + oldItem1 = section.children()[0], + oldItem2 = section.children()[1]; - expect(section.children().length).to.equal(1, 'section contains one child'); + expect(section.children().length).to.equal(2, 'section contains two children'); + expect(oldItem1.children()[0].getText()).to.equal('some item'); + expect(oldItem2.children()[0].getText()).to.equal('some item 2'); }); it('creates two lists with extracted items in the middle if extracting from the middle of the list - nested case' , function() { @@ -619,6 +630,7 @@ describe('Canvas', function() {
\
1.1
\
1.2
\ +
1.3
\
\ \
2
\ @@ -626,25 +638,28 @@ describe('Canvas', function() { '), list = c.doc().children()[0], nestedList = list.children()[1].children()[0], - nestedListItem = nestedList.children()[1]; + nestedListItem1 = nestedList.children()[1], + nestedListItem2 = nestedList.children()[2]; - c.list.extractItems({element1: nestedListItem, element2: nestedListItem, merge: true}); + c.list.extractItems({element1: nestedListItem1, element2: nestedListItem2, merge: true}); var section = c.doc(), list = section.children()[0], item1 = list.children()[0], item2 = list.children()[1], item3 = list.children()[2], - item4 = list.children()[3]; + item4 = list.children()[3], + item5 = list.children()[4]; nestedList = item2.children()[0]; - expect(list.children().length).to.equal(4, 'top list has four items'); + expect(list.children().length).to.equal(5, 'top list has five items'); expect(item1.children()[0].getText()).to.equal('0', 'first item ok'); expect(item2.getWlxmlClass()).to.equal('item', 'nested list is still wrapped in item element'); expect(nestedList.children().length).to.equal(1, 'nested list is left with one child'); expect(nestedList.children()[0].children()[0].getText()).to.equal('1.1', 'nested list item left alone'); - expect(item3.children()[0].getText()).to.equal('1.2', 'second item ok'); - expect(item4.children()[0].getText()).to.equal('2', 'fourth item ok'); + expect(item3.children()[0].getText()).to.equal('1.2', 'third item ok'); + expect(item4.children()[0].getText()).to.equal('1.3', 'fourth item ok'); + expect(item5.children()[0].getText()).to.equal('2', 'fifth item ok'); }); it('puts extracted items above the list if starting item is the first one - nested case' , function() { @@ -656,6 +671,7 @@ describe('Canvas', function() {
\
1.1
\
1.2
\ +
1.3
\
\ \
2
\ @@ -663,25 +679,29 @@ describe('Canvas', function() { '), list = c.doc().children()[0], nestedList = list.children()[1].children()[0], - nestedListItem = nestedList.children()[0]; + nestedListItem1 = nestedList.children()[0], + nestedListItem2 = nestedList.children()[1]; - c.list.extractItems({element1: nestedListItem, element2: nestedListItem, merge: true}); + c.list.extractItems({element1: nestedListItem1, element2: nestedListItem2, merge: true}); var section = c.doc(), list = section.children()[0], item1 = list.children()[0], item2 = list.children()[1], item3 = list.children()[2], - item4 = list.children()[3]; - nestedList = item3.children()[0]; + item4 = list.children()[3], + item5 = list.children()[4]; + nestedList = item4.children()[0]; - expect(list.children().length).to.equal(4, 'top list has four items'); + expect(list.children().length).to.equal(5, 'top list has five items'); expect(item1.children()[0].getText()).to.equal('0', 'first item ok'); expect(item2.children()[0].getText()).to.equal('1.1', 'second item ok'); - expect(item3.getWlxmlClass()).to.equal('item', 'nested list is still wrapped in item element'); + expect(item3.children()[0].getText()).to.equal('1.2', 'third item ok'); + + expect(item4.getWlxmlClass()).to.equal('item', 'nested list is still wrapped in item element'); expect(nestedList.children().length).to.equal(1, 'nested list is left with one child'); - expect(nestedList.children()[0].children()[0].getText()).to.equal('1.2', 'nested list item left alone'); - expect(item4.children()[0].getText()).to.equal('2', 'fourth item ok'); + expect(nestedList.children()[0].children()[0].getText()).to.equal('1.3', 'nested list item left alone'); + expect(item5.children()[0].getText()).to.equal('2', 'fifth item ok'); }); it('removes list if all its items are extracted - nested case', function() { @@ -692,6 +712,7 @@ describe('Canvas', function() {
\
\
1.1
\ +
1.2
\
\
\
2
\ @@ -699,20 +720,23 @@ describe('Canvas', function() { '), list = c.doc().children()[0], nestedList = list.children()[1].children()[0], - nestedListItem = nestedList.children()[0]; + nestedListItem1 = nestedList.children()[0], + nestedListItem2 = nestedList.children()[1]; - c.list.extractItems({element1: nestedListItem, element2: nestedListItem, merge: true}); + c.list.extractItems({element1: nestedListItem1, element2: nestedListItem2, merge: true}); var section = c.doc(), list = section.children()[0], item1 = list.children()[0], item2 = list.children()[1], - item3 = list.children()[2]; + item3 = list.children()[2], + item4 = list.children()[3]; - expect(list.children().length).to.equal(3, 'top list has three items'); + expect(list.children().length).to.equal(4, 'top list has four items'); expect(item1.children()[0].getText()).to.equal('0', 'first item ok'); expect(item2.children()[0].getText()).to.equal('1.1', 'second item ok'); - expect(item3.children()[0].getText()).to.equal('2', 'third item ok'); + expect(item3.children()[0].getText()).to.equal('1.2', 'third item ok'); + expect(item4.children()[0].getText()).to.equal('2', 'fourth item ok'); }); }); });