+ <div wlxml-tag="div">or not</div>\\r
+ </div>'));\r
+ });\r
+ \r
+ test('create from existing nodes - start/end order doesn\'t matter', function() {\r
+ var html = utils.cleanUp('\\r
+ <div wlxml-tag="div">alice</div>\\r
+ <div wlxml-tag="div">cat</div>');\r
+ var expected = utils.cleanUp('\\r
+ <div wlxml-tag="div" wlxml-class="list-items">\\r
+ <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
+ </div>');\r
+ \r
+ var c = canvas.create(html);\r
+ var div_alice = c.findNodes({tag: 'div'})[0];\r
+ var div_cat = c.findNodes({tag:'div'})[1];\r
+ c.listCreate({start: div_cat, end: div_alice});\r
+ assertDomEqual(c.getContent(), expected);\r
+ \r
+ c = canvas.create(html);\r
+ div_alice = c.findNodes({tag: 'div'})[0];\r
+ div_cat = c.findNodes({tag:'div'})[1];\r
+ c.listCreate({start: div_alice, end: div_cat});\r
+ assertDomEqual(c.getContent(), expected);\r
+ });\r
+ \r
+ test('remove', function() {\r
+ var c = canvas.create(utils.cleanUp('\\r
+ <div wlxml-tag="section">\\r
+ <div wlxml-tag="div" wlxml-class="list-items">\\r
+ <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
+ </div>\\r
+ </div>'));\r
+ var item = c.findNodes({klass: 'item'})[1];\r
+ c.listRemove({pointer: item});\r
+ assertDomEqual(c.getContent(), utils.cleanUp('\\r
+ <div wlxml-tag="section">\\r
+ <div wlxml-tag="div">alice</div>\\r
+ <div wlxml-tag="div">cat</div>\\r
+ </div>'));\r
+ });\r
+ \r
+ test('checking if node is inside a list', function() {\r
+ var c = canvas.create(utils.cleanUp('\\r
+ <div wlxml-tag="section">\\r
+ <div wlxml-tag="div" wlxml-class="list-items-enum">\\r
+ <div wlxml-tag="div" wlxml-class="item">alice <span wlxml-tag="span"></span</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
+ </div>\\r
+ </div>'));\r
+ assert.ok(c.nodeInsideList({node: c.findNodes({klass: 'item'})[1]}), 'item is inside a list');\r
+ assert.ok(c.nodeInsideList({node: c.findNodes({tag: 'span'})[0]}), 'things nested in item are inside a list');\r
+ });\r
+ \r
+ test('moving items to nested list', function() {\r
+ var listHTML = utils.cleanUp('\\r
+ <div wlxml-tag="div" wlxml-class="list-items">\\r
+ <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">dog</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">bee</div>\\r
+ </div>');\r
+ var c = canvas.create(listHTML);\r
+ var items = c.findNodes({klass: 'item'});\r
+ var cat_item = items[1];\r
+ var dog_item = items[2];\r
+ \r
+ c.listCreate({start: cat_item, end: dog_item});\r
+ \r
+ assertDomEqual(c.getContent(), utils.cleanUp('\\r
+ <div wlxml-tag="div" wlxml-class="list-items">\\r
+ <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">\\r
+ <div wlxml-tag="div" wlxml-class="list-items">\\r
+ <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">dog</div>\\r
+ </div>\\r
+ </div>\\r
+ <div wlxml-tag="div" wlxml-class="item">bee</div>\\r
+ </div>'\r
+ ));\r
+ });\r
+ \r
+ test('removing nested list', function() {\r
+ var nestedList = utils.cleanUp('\\r
+ <div wlxml-tag="div" wlxml-class="list-items">\\r
+ <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">\\r
+ <div wlxml-tag="div" wlxml-class="list-items">\\r
+ <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">dog</div>\\r
+ </div>\\r
+ </div>\\r
+ <div wlxml-tag="div" wlxml-class="item">bee</div>\\r
+ </div>');\r
+ \r
+ var c = canvas.create(nestedList);\r
+ var dog_item = c.findNodes('[wlxml-class=list-items] [wlxml-class=list-items] > div')[1];\r
+ assert.equal(dog_item.getContent(), 'dog');\r
+ \r
+ c.listRemove({pointer: dog_item});\r
+ \r
+ assertDomEqual(c.getContent(), utils.cleanUp('\\r
+ <div wlxml-tag="div" wlxml-class="list-items">\\r
+ <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">dog</div>\\r
+ <div wlxml-tag="div" wlxml-class="item">bee</div>\\r
+ </div>'));\r
+ \r
+ \r