+
+ describe('Searching for the last child text node', function() {
+ [
+ '<div>xxx<div></div>last</div>',
+ '<div><div>last</div></div>',
+ '<div>xxx<div>last</div><div></div></div>'
+ ].forEach(function(xml, i) {
+ var example = 'example ' + i;
+ it('returns last child text node ' + example + ')', function() {
+ var doc = getDocumentFromXML(xml),
+ lastTextNode = doc.root.getLastTextNode();
+ expect(lastTextNode.getText()).to.equal('last', example);
+ });
+ });
+ });
+
+ describe('Putting nodes around', function() {
+ it('will not allow to put node before or after root node', function() {
+ var doc = getDocumentFromXML('<root></root>'),
+ spy = sinon.spy(),
+ root = doc.root,
+ result;
+
+ doc.on('change', spy);
+
+ result = doc.root.before({tagName: 'test'});
+
+ expect(spy.callCount).to.equal(0);
+ expect(result).to.undefined;
+
+ result = doc.root.after({tagName: 'test'});
+
+ expect(spy.callCount).to.equal(0);
+ expect(result).to.undefined;
+
+ expect(doc.root.sameNode(root));
+ });
+ });