X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/5a57bc3cb22f2cb424186d8a7992d7dc7af68326..3dfe15d50b60598341b9754876db4a48162c5cd0:/src/smartxml/smartxml.test.js?ds=inline diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index 93c401b..f506f09 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -105,9 +105,10 @@ describe('smartxml', function() { }); it('can be cloned with its contents and its contents data', function() { - var doc = getDocumentFromXML('
'), + var doc = getDocumentFromXML('
text
'), root = doc.root, - div = root.contents()[0]; + div = root.contents()[0], + text = div.contents()[0]; var ClonableObject = function(arg) { this.arg = arg; @@ -118,15 +119,19 @@ describe('smartxml', function() { div.setData('key', 'value'); div.setData('clonableObject', new ClonableObject('test')); + text.setData('key', 'value'); var rootClone = root.clone(), divClone = rootClone.contents()[0], + textClone = divClone.contents()[0], stringClone = divClone.getData('key'), objClone = divClone.getData('clonableObject'); expect(stringClone).to.equal('value'); expect(objClone.arg).to.equal('test', 'clonable object got copied'); expect(objClone !== div.getData('clonableObject')).to.be.equal(true, 'copy of the clonable object is a new object'); + + expect(textClone.getData('key')).to.be.equal(undefined, 'cloning text node data is not supported yet'); }); it('knows its path in the document tree', function() { @@ -767,10 +772,7 @@ describe('smartxml', function() { }); it('keeps parent-describing nodes in place', function() { - var section = elementNodeFromXML('
Alice
a cat
'), - aliceText = section.contents()[0], - x = section.contents()[1], - lastDiv = section.contents()[2]; + var section = elementNodeFromXML('
Alice
a cat
'); section.document.registerExtension({documentNode: {methods: { object: { @@ -780,6 +782,10 @@ describe('smartxml', function() { } }}}); + var aliceText = section.contents()[0], + x = section.contents()[1], + lastDiv = section.contents()[2]; + section.document.wrapNodes({ node1: aliceText, node2: lastDiv,