editor: fix
[fnpeditor.git] / src / wlxml / extensions / list / list.test.js
index fd6089e..2d47778 100644 (file)
@@ -60,6 +60,15 @@ describe('Lists extension', function() {
             expect(child3.contents()[0].getText()).to.equal('cat');
         });
 
             expect(child3.contents()[0].getText()).to.equal('cat');
         });
 
+        it('Handles text nodes on the boundries', function() {
+            var doc = getDocumentFromXML('<section>Alice<span>has</span>a cat</section>'),
+                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('\
                 <section>\
         it('allows creating nested list from existing sibling list items', function() {
             var doc = getDocumentFromXML('\
                 <section>\
@@ -148,8 +157,7 @@ describe('Lists extension', function() {
                 </section>')),
                 list = doc.root.contents()[0],
                 item1 = list.contents()[0],
                 </section>')),
                 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});
 
 
             doc.extractItems({item1: item1, item2: item2});
 
@@ -175,7 +183,6 @@ describe('Lists extension', function() {
                     </div>\
                 </section>')),
                 list = doc.root.contents()[0],
                     </div>\
                 </section>')),
                 list = doc.root.contents()[0],
-                item1 = list.contents()[0],
                 item2 = list.contents()[1],
                 item3 = list.contents()[2];
 
                 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});
 
 
             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];
 
             var sectionContents = section.contents(),
                 extractedItem = sectionContents[1];