Describing internal HTML represenation of a sample document
[fnpeditor.git] / modules / documentCanvas / canvas / canvas.test3.js
index 3c25cf5..e122a1a 100644 (file)
@@ -11,6 +11,30 @@ var expect = chai.expect;
 
 describe('Canvas', function() {
 
+    describe('Internal HTML representation of a sample document', function() {
+        it('works', function() {
+            var c = canvas.fromXML('\
+                <section>\
+                    This is some text without its own wrapping tag.\
+                    <div class="p.subclass">\
+                        This is a paragraph.\
+                    </div>\
+                    <div>\
+                        This is text in a div <span>with some inline text</span>.\
+                    </div>\
+                    This is some text without its own wrapping tag.\
+                </section>\
+            ');
+            var expected = '<div wlxml-tag="section">'
+                            + 'This is some text without its own wrapping tag.'
+                            + '<div wlxml-tag="div" wlxml-class="p-subclass">This is a paragraph.</div>'
+                            + '<div wlxml-tag="div">This is text in a div <div wlxml-tag="span">with some inline text</div>.</div>'
+                            + 'This is some text without its own wrapping tag.'
+                            + '</div>';
+            expect(c.doc().dom()[0].isEqualNode($(expected)[0])).to.be.true;
+        });
+    });
+
     describe('Internal HTML representation of a DocumentNodeElement', function() {
         it('is always a div tag', function() {
             ['section', 'header', 'span', 'aside', 'figure'].forEach(function(tagName) {
@@ -162,6 +186,7 @@ describe('Canvas', function() {
                     var c = canvas.fromXML('<section> </section>');
                     expect(c.doc().children().length).to.equal(1);
                     expect(c.doc().children()[0]).to.be.instanceOf(documentElement.DocumentTextElement);
+                    expect(c.doc().children()[0].getText()).to.equal(' ');
                 });
                 it('ignores white space surrounding block elements', function() {
                     var c = canvas.fromXML('<section> <div></div> </section>');
@@ -415,6 +440,9 @@ describe('Canvas', function() {
                 var list = section.children()[0];
                 expect(list.is('list')).to.equal(true, 'section\'s only child is a list');
                 expect(list.children().length).to.equal(4, 'list contains four elements');
+                list.children().forEach(function(child) {
+                    expect(child.getWlxmlClass()).to.equal('item', 'list childs have wlxml class of item');
+                });
             });
         });