comparing nodes
[fnpeditor.git] / modules / documentCanvas / canvas / canvas.test3.js
index 4ed6ce1..b041bac 100644 (file)
@@ -32,12 +32,30 @@ describe('Canvas', function() {
             });
         });
 
+        describe('DocumentElements comparison', function() {
+            it('reports dwo DocumentElements to be the same when they represent the same wlxml document element', function() {
+                var c = canvas.fromXML('<section><div></div><div></div></section>'),
+                    first_div1 = c.doc().children()[0],
+                    first_div2 = c.doc().children()[0],
+                    second_div = c.doc().children()[1];
+                expect(first_div1.sameNode(first_div1)).to.be.true;
+                expect(first_div1.sameNode(first_div2)).to.be.true;
+                expect(first_div1.sameNode(second_div)).to.be.false;
+            });
+        });
+
         describe('traversing', function() {
             it('reports element nodes', function() {
                 var c = canvas.fromXML('<section><div></div></section>'),
                     children = c.doc().children();
                 expect(children.length).to.equal(1);
                 expect(children[0]).to.be.instanceOf(documentElement.DocumentNodeElement);
+
+                c = canvas.fromXML('<section><div></div><div></div></section>'),
+                    children = c.doc().children();
+                expect(children.length).to.equal(2);
+                expect(children[0]).to.be.instanceOf(documentElement.DocumentNodeElement);
+                expect(children[1]).to.be.instanceOf(documentElement.DocumentNodeElement);
             });
             it('reports text nodes', function() {
                 var c = canvas.fromXML('<section>Alice</section>'),