appending node elements
[fnpeditor.git] / modules / documentCanvas / canvas / canvas.test3.js
index b6cc42e..8af9797 100644 (file)
@@ -116,6 +116,49 @@ describe('Canvas', function() {
             });
         })
 
+        describe('manipulation api', function() {
+            
+
+
+            describe('Basic Element inserting', function() {
+                it('can put new NodeElement at the end', function() {
+                    var c = canvas.fromXML('<section></section>'),
+                        appended = c.doc().append({tag: 'header', klass: 'some.class'}),
+                        children = c.doc().children();
+
+                    expect(children.length).to.equal(1);
+                    expect(children[0].sameNode(appended));
+                });
+
+                //it('can')
+            });
+
+            describe('wrapping', function() {
+                it('wraps DocumentNodeElement', function() {
+                    var c = canvas.fromXML('<section><div></div></section>'),
+                        div = c.doc().children()[0];
+                    
+                    var returned = div.wrapWithNodeElement({tag: 'header', klass: 'some.class'}),
+                        parent = div.parent(),
+                        parent2 = c.doc().children()[0];
+
+                    expect(returned.sameNode(parent)).to.be.true;
+                    expect(returned.sameNode(parent2)).to.be.true;
+                });
+                it('wraps DocumentTextElement', function() {
+                    var c = canvas.fromXML('<section>Alice</section>'),
+                        text = c.doc().children()[0];
+                    
+                    var returned = text.wrapWithNodeElement({tag: 'header', klass: 'some.class'}),
+                        parent = text.parent(),
+                        parent2 = c.doc().children()[0];
+
+                    expect(returned.sameNode(parent)).to.be.true;
+                    expect(returned.sameNode(parent2)).to.be.true;
+                });
+            })
+        });
+
     });
 });