- describe('when text preceded by element', function() {
- describe('when text followed by element', function() {
- it('appends text to the preceding element, following elements stays in place', function() {
- var doc = getDocumentFromXML('<section><a>A</a>text<b>B</b></section>'),
- text = getTextNode('text', doc);
-
- text.mergeContentUp();
- var contents = doc.root.contents();
-
- expect(contents.length).to.equal(2);
- expect(contents[0].getTagName()).to.equal('a');
- expect(contents[0].contents()[0].getText()).to.equal('Atext');
- expect(contents[1].getTagName()).to.equal('b');
- });
- });
- describe('when text is a last child', function() {
- it('appends text to the preceding element', function() {
- var doc = getDocumentFromXML('<section><a>A</a>text</section>'),
- text = getTextNode('text', doc);
-
- text.mergeContentUp();
- var contents = doc.root.contents();
-
- expect(contents.length).to.equal(1);
- expect(contents[0].getTagName()).to.equal('a');
- expect(contents[0].contents()[0].getText()).to.equal('Atext');
- });
- });
- });
+ doc.on('change', spy);
+ text.mergeContentUp();
+ expect(spy.callCount).to.equal(0);
+ });
+ it('does nothing if text node parent is precedeed by text node', function() {
+ var doc = getDocumentFromXML('<section><div></div>another text<div>some text</div></section>'),
+ text = getTextNode('some text', doc),
+ spy = sinon.spy();
+
+ doc.on('change', spy);
+ text.mergeContentUp();
+ expect(spy.callCount).to.equal(0);
+ });
+ it('does nothing if text node is not first child of its parent', function() {
+ var doc = getDocumentFromXML('<section><div></div><div><a></a>some text</div></section>'),
+ text = getTextNode('some text', doc),
+ spy = sinon.spy();