X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/cee08f0b14be951a31544ae708b2a92f6255e61a..989364fcf105797896a7172a4c9367f6b07848b2:/src/wlxml/extensions/list/list.test.js?ds=sidebyside
diff --git a/src/wlxml/extensions/list/list.test.js b/src/wlxml/extensions/list/list.test.js
index faa85da..396600b 100644
--- a/src/wlxml/extensions/list/list.test.js
+++ b/src/wlxml/extensions/list/list.test.js
@@ -2,6 +2,9 @@ define(function(require) {
'use strict';
+/* jshint multistr:true */
+/* globals describe, it */
+
var chai = require('libs/chai'),
wlxml = require('wlxml/wlxml'),
expect = chai.expect,
@@ -16,6 +19,7 @@ var getDocumentFromXML = function(xml, options) {
};
var removeEmptyTextNodes = function(xml) {
+ /* globals Node */
xml = $($.trim(xml));
xml.find(':not(iframe)')
.addBack()
@@ -56,6 +60,15 @@ describe('Lists extension', function() {
expect(child3.contents()[0].getText()).to.equal('cat');
});
+ it('Handles text nodes on the boundries', 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('\
\
@@ -144,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});
@@ -171,7 +183,6 @@ describe('Lists extension', function() {
\
')),
list = doc.root.contents()[0],
- item1 = list.contents()[0],
item2 = list.contents()[1],
item3 = list.contents()[2];
@@ -233,9 +244,8 @@ describe('Lists extension', function() {
doc.extractItems({item1: nestedListItem, item2: nestedListItem}); //@@ name!
- var section = doc.root,
- list = section.contents()[0],
- item1 = list.contents()[0],
+ list = doc.root.contents()[0];
+ var item1 = list.contents()[0],
item2 = list.contents()[1], //
item3 = list.contents()[2],
item4 = list.contents()[3], //
@@ -281,10 +291,8 @@ describe('Lists extension', function() {
nestedListItem2 = nestedList.contents()[2];
doc.extractItems({item1: nestedListItem1, item2: nestedListItem2});
-
- var section = doc.root,
- list = section.contents()[0],
- item1 = list.contents()[0],
+ list = doc.root.contents()[0];
+ var item1 = list.contents()[0],
item2 = list.contents()[1],
item3 = list.contents()[2],
item4 = list.contents()[3],
@@ -323,9 +331,8 @@ describe('Lists extension', function() {
doc.extractItems({item1: nestedListItem1, item2: nestedListItem2});
- var section = doc.root,
- list = section.contents()[0],
- item1 = list.contents()[0],
+ list = doc.root.contents()[0];
+ var item1 = list.contents()[0],
item2 = list.contents()[1],
item3 = list.contents()[2],
item4 = list.contents()[3],
@@ -364,9 +371,8 @@ describe('Lists extension', function() {
doc.extractItems({item1: nestedListItem1, item2: nestedListItem2});
- var section = doc.root,
- list = section.contents()[0],
- item1 = list.contents()[0],
+ list = doc.root.contents()[0];
+ var item1 = list.contents()[0],
item2 = list.contents()[1],
item3 = list.contents()[2],
item4 = list.contents()[3];