X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/30ab52867dd38bdf8bda76e60be833b2603fb6ab..7b4405539ac7c11a11b5259b4f968e1289f0b2a7:/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 6ba3f42..35f0d85 100644 --- a/modules/documentCanvas/tests/canvas.test.js +++ b/modules/documentCanvas/tests/canvas.test.js @@ -54,6 +54,20 @@ define([ assert.equal(header.tag, 'header'); assert.equal(header.klass, 'some-class'); }); + + test('getting previous node', function() { + var c = new canvas.Canvas('
Div 1
Div 2
'); + var secondDiv = c.getNode({tag: 'div'})[1]; + var firstDiv = c.getPreviousNode({node: secondDiv}); + assert.equal(firstDiv.klass, 'some-class'); + }) + + test('pervious node of node without "previous siblings" is its parent', function() { + var c = new canvas.Canvas('
Div 1
'); + var div = c.getNode({tag: 'div'})[0]; + var section = c.getPreviousNode({node: div}); + assert.equal(section.tag, 'section'); + }) test('inserting after', function() { var c = new canvas.Canvas('
Header 1
'); @@ -104,8 +118,8 @@ define([ ); }); - test('list', function() { - var c = new canvas.Canvas('
Alice
has
a cat
'); + test('create list from existing nodes', function() { + var c = new canvas.Canvas('
Alice
has
a cat
some text
'); var div1 = c.getNode({tag:'div'})[0]; var div2 = c.getNode({tag:'div'})[1]; @@ -113,13 +127,36 @@ define([ assert.xmlEqual(c.toXML(), '\
\ -
\ -
Alice
\ -
has
\ -
a cat
\ +
\ +
Alice
\ +
has
\ +
a cat
\
\ +
some text
\ +
'); + + }); + + test('remove list', function() { + var xml = '\ +
\ +
\ +
Alice
\ +
has
\ +
a cat
\ +
\ +
some text
\ +
'; + var c = new canvas.Canvas(xml); + var item = c.getNode({klass: 'item'})[1]; + c.removeList({pointer: item}); + assert.xmlEqual(c.toXML(), '\ +
\ +
Alice
\ +
has
\ +
a cat
\ +
some text
\
'); - }); });