smartxml: throw exception on missing tagName property sent to createDocumentNode
[fnpeditor.git] / src / smartxml / smartxml.test.js
index d82f823..57f11cc 100644 (file)
@@ -60,6 +60,15 @@ describe('smartxml', function() {
             expect(emptyTextNode.getText()).to.equal('', 'empty ok');
             expect(nonEmptyTextNode.getText()).to.equal('alice', 'non empty ok');
         });
+
+        it('creates nodes from xml strings', function() {
+            var doc = getDocumentFromXML('<div></div>'),
+                node = doc.createDocumentNode('<a>Alice<b></b></a>');
+            expect(node.getTagName()).to.equal('a');
+            expect(node.contents().length).to.equal(2);
+            expect(node.contents()[0].getText()).to.equal('Alice');
+            expect(node.contents()[1].getTagName()).to.equal('b');
+        });
     });
 
     describe('DocumentNode', function() {
@@ -1264,6 +1273,13 @@ describe('smartxml', function() {
                 expect(doc.root.getAttr('test'), '3');
             });
 
+            it('ignores empty transactions', function() {
+                var doc = getDocumentFromXML('<div></div>');
+                doc.startTransaction();
+                doc.endTransaction();
+                expect(doc.undoStack).to.have.length(0, 'empty transaction doesn\'t get pushed into undo stack');
+            });
+
             it('doesn\'t break on optimizations', function() {
                 // This is a smoke test checking if optimizations made to transaction undoing
                 // doesnt't break anything.