X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/dca8878022514685dba90359231cdfb872cab1cb..6cd9ff4975ba90953d3c6b3918e4c7a76af6d348:/src/editor/plugins/core/core.test.js diff --git a/src/editor/plugins/core/core.test.js b/src/editor/plugins/core/core.test.js index 67e3e7e..00fc421 100644 --- a/src/editor/plugins/core/core.test.js +++ b/src/editor/plugins/core/core.test.js @@ -700,6 +700,26 @@ describe('Keyboard interactions', function() { }); }); + describe('Deleting text from a node', function() { + it('deletes last character with backspace', function() { + var c = getCanvasFromXML('
a
b
'), + k = new Keyboard(c); + + k.withCaret('b|').press(K.BACKSPACE); + + var rootContents = c.wlxmlDocument.root.contents(); + expect(rootContents.length).to.equal(2); + expect(rootContents[0].is({tagName: 'div', klass: 'p'})).to.equal(true); + expect(rootContents[0].contents()[0].getText()).to.equal('a'); + expect(rootContents[1].is({tagName: 'div', klass: 'p'})).to.equal(true); + expect(rootContents[1].contents()[0].getText()).to.equal(''); + + var selection = c.getSelection(); + expect(selection.type).to.equal('caret'); + expect(selection.element.sameNode(getTextElement('', c))).to.equal(true); + expect(selection.offset).to.equal(0); + }); + }); });