X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/4ac9bc0d440f080281210f023fb9d8c1da42dadd..969f365b3ee6d3cb54f98b23e1ebb97df9f801dd:/modules/documentCanvas/tests/canvas.test.js?ds=sidebyside
diff --git a/modules/documentCanvas/tests/canvas.test.js b/modules/documentCanvas/tests/canvas.test.js
index fc842e5..ac3e69a 100644
--- a/modules/documentCanvas/tests/canvas.test.js
+++ b/modules/documentCanvas/tests/canvas.test.js
@@ -57,10 +57,26 @@ define([
var c = canvas.create('
');
var header = c.findNodes({tag: 'header'})[0];
var wrapper = canvasNode.create({tag: 'aside'});
- c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 6})
+ c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 6});
assertDomEqual(c.getContent(), '');
});
+ test('wrap text in node - text not a first node', function() {
+ var c = canvas.create('Alice has a cat
');
+ var header = c.findNodes({tag: 'header'})[0];
+ var wrapper = canvasNode.create({tag: 'aside'});
+ c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 4, textNodeIdx: 2});
+ assertDomEqual(c.getContent(), 'Alice has a cat
');
+ });
+
+ test('wrap text with nodes inside', function() {
+ var c = canvas.create('Alice has a small cat
');
+ var header = c.findNodes({tag: 'header'})[0];
+ var wrapper = canvasNode.create({tag: 'aside'});
+ c.nodeWrap({inside: header, _with: wrapper, offsetStart: 6, offsetEnd: 4, textNodeIdx: [0,2]});
+ assertDomEqual(c.getContent(), 'Alice has a small cat
');
+ });
+
test('split node', function() {
var c = canvas.create('');
var header = c.findNodes({tag: 'header'})[0];
@@ -186,5 +202,64 @@ define([
assert.ok(c.nodeInsideList({node: c.findNodes({klass: 'item'})[1]}), 'item is inside a list');
assert.ok(c.nodeInsideList({node: c.findNodes({tag: 'span'})[0]}), 'things nested in item are inside a list');
});
+
+ test('moving items to nested list', function() {
+ var listHTML = utils.cleanUp('\
+ \
+
alice
\
+
cat
\
+
dog
\
+
bee
\
+
');
+ var c = canvas.create(listHTML);
+ var items = c.findNodes({klass: 'item'});
+ var cat_item = items[1];
+ var dog_item = items[2];
+
+ c.listCreate({start: cat_item, end: dog_item});
+
+ assertDomEqual(c.getContent(), utils.cleanUp('\
+ '
+ ));
+ });
+
+ test('removing nested list', function() {
+ var nestedList = utils.cleanUp('\
+ ');
+
+ var c = canvas.create(nestedList);
+ var dog_item = c.findNodes('[wlxml-class=list-items] [wlxml-class=list-items] > div')[1];
+ assert.equal(dog_item.getContent(), 'dog');
+
+ c.listRemove({pointer: dog_item});
+
+ assertDomEqual(c.getContent(), utils.cleanUp('\
+ \
+
alice
\
+
cat
\
+
dog
\
+
bee
\
+
'));
+
+
+ });
});
});
\ No newline at end of file