X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/4c81ad4075b0e8e67f984cce3494f9853179a9d6..52f3927cfc1af1e9eaa469b73a33c9575ef710d8:/modules/documentCanvas/tests/canvas.test.js diff --git a/modules/documentCanvas/tests/canvas.test.js b/modules/documentCanvas/tests/canvas.test.js index a948787..7515309 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
'); @@ -93,8 +107,19 @@ define([ ); }); - test('list', function() { - var c = new canvas.Canvas('
Alice
has
a cat
'); + test('remove node', function() { + var c = new canvas.Canvas('
Fancy and nice header 1
'); + var span = c.getNode({tag: 'span'})[0]; + var siblings = c.removeNode({node:span}); + assert.xmlEqual(c.toXML(), '\ +
\ +
Fancy and nice 1
\ +
' + ); + }); + + 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]; @@ -102,13 +127,14 @@ define([ assert.xmlEqual(c.toXML(), '\
\ -
\ -
Alice
\ -
has
\ -
a cat
\ +
\ +
Alice
\ +
has
\ +
a cat
\
\ +
some text
\
'); - + }); });