X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/21cd91531dd9c6e88d00da03f6b2f3ad88fb0da0..7263e5132059abc0e93deac2175db475f90e7617:/src/wlxml/extensions/list/list.test.js?ds=inline
diff --git a/src/wlxml/extensions/list/list.test.js b/src/wlxml/extensions/list/list.test.js
index fd6089e..2887b4f 100644
--- a/src/wlxml/extensions/list/list.test.js
+++ b/src/wlxml/extensions/list/list.test.js
@@ -60,6 +60,15 @@ describe('Lists extension', function() {
expect(child3.contents()[0].getText()).to.equal('cat');
});
+ it('Handles text nodes on the boundaries', function() {
+ var doc = getDocumentFromXML(''),
+ textNode1 = doc.root.contents()[0],
+ textNode2 = doc.root.contents()[2];
+ doc.createList({node1: textNode1, node2: textNode2});
+ expect(doc.root.contents().length).to.equal(1);
+ expect(doc.root.contents()[0].is('list')).to.equal(true);
+ });
+
it('allows creating nested list from existing sibling list items', function() {
var doc = getDocumentFromXML('\
\
@@ -127,10 +136,10 @@ describe('Lists extension', function() {
expect(list1.contents()[0].contents()[0].getText()).to.equal('0', 'first item of the first list is a first item of the original list');
expect(oldItem1.contents()[0].getText()).to.equal('1', 'first item got extracted');
- expect(oldItem1.getClass() === '').to.equal(true, 'first extracted element has no wlxml class');
+ expect(oldItem1.getClass() === 'p').to.equal(true, 'first extracted element became a paragraph');
expect(oldItem2.contents()[0].getText()).to.equal('2', 'second item got extracted');
- expect(oldItem2.getClass() === '').to.equal(true, 'second extracted element has no wlxml class');
+ expect(oldItem2.getClass() === 'p').to.equal(true, 'second extracted element became a paragraph');
expect(list2.is('list')).to.equal(true, 'last section child is a list');
expect(list2.contents().length).to.equal(1, 'second list has one child');
@@ -148,8 +157,7 @@ describe('Lists extension', function() {
')),
list = doc.root.contents()[0],
item1 = list.contents()[0],
- item2 = list.contents()[1],
- item3 = list.contents()[2];
+ item2 = list.contents()[1];
doc.extractItems({item1: item1, item2: item2});
@@ -175,7 +183,6 @@ describe('Lists extension', function() {
\
')),
list = doc.root.contents()[0],
- item1 = list.contents()[0],
item2 = list.contents()[1],
item3 = list.contents()[2];
@@ -398,7 +405,7 @@ describe('Lists extension', function() {
var test = doc.extractItems({item1: nestedListItem, item2: nestedListItem, merge: false});
- expect(test).to.equal(true, 'extraction status ok');
+ expect(test.sameNode(nestedListItem)).to.equal(true, 'first item returned');
var sectionContents = section.contents(),
extractedItem = sectionContents[1];
@@ -407,7 +414,7 @@ describe('Lists extension', function() {
expect(sectionContents[0].is('list')).to.equal(true, 'first child is a list');
expect(extractedItem.getTagName()).to.equal('div', 'extracted item is a wlxml div');
- expect(extractedItem.getClass()).to.equal('', 'extracted item has no wlxml class');
+ expect(extractedItem.getClass()).to.equal('p', 'extracted item became a paragraph');
expect(extractedItem.contents()[0].getText()).to.equal('1.1', 'extracted item ok');
expect(sectionContents[2].is('list')).to.equal(true, 'second child is a list');
});