X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/0bea7025f60aa5cc2ed89eed72da0d616f3574ef..e0aad96df245c7148966887cbcc77417a4b7675b:/src/editor/modules/documentCanvas/canvas/canvas.test.js?ds=sidebyside diff --git a/src/editor/modules/documentCanvas/canvas/canvas.test.js b/src/editor/modules/documentCanvas/canvas/canvas.test.js index 8e3c1c8..9059e3f 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.test.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.test.js @@ -12,8 +12,8 @@ define([ var expect = chai.expect; -var getCanvasFromXML = function(xml) { - return canvas.fromXMLDocument(getDocumentFromXML(xml), null); +var getCanvasFromXML = function(xml, elements) { + return canvas.fromXMLDocument(getDocumentFromXML(xml), elements); }; var getDocumentFromXML = function(xml) { @@ -35,7 +35,7 @@ describe('wtf', function() { txtNode.wrapWith({tagName: 'header', start: 1, end: 2}); expect(c.doc().children().length).to.equal(3); }); -}) +}); describe('new Canvas', function() { it('abc', function() { @@ -81,7 +81,6 @@ describe('Listening to document changes', function() { b = doc.root.contents()[1], c = canvas.fromXMLDocument(doc); - debugger; a.before(b); var sectionChildren = c.doc().children(); expect(sectionChildren.length).to.equal(2); @@ -229,34 +228,34 @@ describe('Default document changes handling', function() { describe('Custom elements based on wlxml class attribute', function() { it('allows custom rendering', function() { - var c = getCanvasFromXML('
', { - testClass: { + var c = getCanvasFromXML('
', [ + {tag: 'div', klass: 'testClass', prototype: { init: function() { - debugger; - this.dom.append(''); + this._container().append(''); } - } - }); + }, extending: {tag: 'div'}} + ]); + expect(c.doc().children()[0]._container().children('test').length).to.equal(1); // @! }); it('allows handling changes to internal structure of rendered node', function() { - var c = getCanvasFromXML('
', { - testClass: { + var c = getCanvasFromXML('
', [ + {tag: 'div', klass: 'testClass', prototype: { init: function() { this.header = $('

'); - this.dom.append(this.header); + this._container().append(this.header); this.refresh2(); }, refresh2: function() { - this.header.text(this.el.wlxmlNode.contents().length); + this.header.text(this.wlxmlNode.contents().length); }, onNodeAdded: function(event) { void(event); this.refresh2(); } - } - }); + }, extending: {tag: 'div'}} + ]); var node = c.wlxmlDocument.root.contents()[0], element = node.getData('canvasElement');