X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/393685bcd5f1b3cf31cdea0cf36c2ac7e44f31c3..a1c752a1fd15569e947246924254c2a072462fb8:/modules/documentCanvas/canvas/canvas.test3.js diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index df95a78..51f4f0a 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -1102,6 +1102,26 @@ describe('Canvas', function() { expect(input.isEqualNode(output)).to.be.true; }); + it('keeps arbitrary node attributes intact', function() { + var xmlIn = '
', + $xmlOut = $(canvas.fromXML(xmlIn).toXML()); + + expect($xmlOut.attr('a')).to.equal('1'); + expect($xmlOut.attr('xmlns:dcterms')).to.equal('http://purl.org/dc/terms/'); + }); + + it('doesn\' serialize meta attribute if its empty', function() { + var c; + + c = canvas.fromXML('
'); + c.doc().setWlxmlMetaAttr('uri', ''); + expect($(c.toXML()).attr('meta-uri')).to.equal(undefined, 'overriding attribute with zero length string'); + + c = canvas.fromXML('
'); + c.doc().setWlxmlMetaAttr('uri', ''); + expect($(c.toXML()).attr('meta-uri')).to.equal(undefined, 'setting attribute to zero length string'); + }); + describe('formatting output xml', function() { /*it('keeps white spaces at the edges of input xml', function() { var xmlIn = '
', @@ -1122,7 +1142,18 @@ describe('Canvas', function() { expect(partsIn).to.deep.equal(partsOut); }); - it('nests new children elements', function() { + it('keeps white space between XML nodes - inline case', function() { + var xmlIn = '
\n\n\n\n\n\n\n\n\n
', + c = canvas.fromXML(xmlIn), + xmlOut = c.toXML(); + + var partsIn = xmlIn.split('\n\n\n'), + partsOut = xmlOut.split('\n\n\n'); + + expect(partsIn).to.deep.equal(partsOut); + }); + + it('nests new children block elements', function() { var c = canvas.fromXML('
'); c.doc().append({tag: 'header'}); @@ -1132,6 +1163,31 @@ describe('Canvas', function() { expect(xmlOut.split('\n').slice(-1)[0]).to.equal('', 'nesting end ok'); }); + + it('doesn\'t nest new children inline elements', function() { + var c = canvas.fromXML('
'); + + c.doc().append({tag: 'span'}); + + var xmlOut = c.toXML(); + expect(xmlOut).to.equal('
'); + }); + + it('keeps original white space at the end of text', function() { + + var xmlIn = '
Some text ended with white space \ + \ + Some text some text\ + \ +
', + c = canvas.fromXML(xmlIn); + + var xmlOut = c.toXML(); + console.log(xmlOut); + expect(xmlOut).to.equal(xmlIn); + + }); + }) }) });