X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/7bd1d1364915cd2ead33d97a4396c69e22b39713..4ddf36452af460dbc26fd181f2ba3640a7c71374:/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 5c36f90..10a2376 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.test.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.test.js @@ -19,6 +19,9 @@ var getCanvasFromXML = function(xml) { return canvas.fromXMLDocument(wlxml.WLXMLDocumentFromXML(xml)); }; +var wait = function(callback, timeout) { + return window.setTimeout(callback, timeout || 0.5); +} describe('new Canvas', function() { it('abc', function() { @@ -29,6 +32,21 @@ describe('new Canvas', function() { }); }) +describe('Handling empty text nodes', function() { + it('puts zero width space into node with about to be remove text', function(done) { + var c = getCanvasFromXML('
Alice
'), + textElement = c.doc().children()[0]; + textElement.setText(''); + + /* Wait for MutationObserver to kick in. */ + wait(function() { + expect(textElement.getText({raw:true})).to.equal(utils.unicode.ZWS, 'ZWS in canvas'); + expect(c.wlxmlDocument.root.contents()[0].getText()).to.equal('', 'empty string in a document'); + done(); + }); + }); +}); + describe('Cursor', function() { var getSelection;