X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/1cbef89f1995ae8bb83d01a58d20b005ad8b3a8f..39f891f942d26b4048bf5f4e32fc235b33f36b26:/src/smartxml/smartxml.test.js
diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js
index 8ae7721..cbef963 100644
--- a/src/smartxml/smartxml.test.js
+++ b/src/smartxml/smartxml.test.js
@@ -754,6 +754,42 @@ describe('smartxml', function() {
expect(contents.length).to.equal(1);
expect(contents[0].getText()).to.equal('Acat');
});
+ it('remove across elements - 4', function() {
+ var doc = getDocumentFromXML('
');
+ doc.deleteText({
+ from: {
+ node: getTextNode('Alice ', doc),
+ offset: 1
+ },
+ to: {
+ node: getTextNode(' cat', doc),
+ offset: 1
+ }
+ });
+ var contents = doc.root.contents();
+ expect(contents.length).to.equal(2);
+ expect(contents[0].getText()).to.equal('A');
+ expect(contents[1].getTagName()).to.equal('div');
+ expect(contents[1].contents().length).to.equal(1);
+ expect(contents[1].contents()[0].getText()).to.equal('cat');
+ });
+ it('removes across elements - 5 (whole document)', function() {
+ var doc = getDocumentFromXML('');
+ doc.deleteText({
+ from: {
+ node: getTextNode('Alice ', doc),
+ offset: 0
+ },
+ to: {
+ node: getTextNode('!!!', doc),
+ offset: 3
+ }
+ });
+
+ expect(doc.root.getTagName()).to.equal('div');
+ expect(doc.root.contents().length).to.equal(1);
+ expect(doc.root.contents()[0].getText()).to.equal('');
+ });
it('removes nodes in between', function() {
var doc = getDocumentFromXML('');
doc.deleteText({