wip: canvas.commands - lists through new api
[fnpeditor.git] / src / smartxml / smartxml.test.js
index 3175ae9..08598aa 100644 (file)
@@ -769,7 +769,9 @@ describe('smartxml', function() {
                     c = b.contents()[0];
 
                 var parents = c.parents();
                     c = b.contents()[0];
 
                 var parents = c.parents();
-                expect(parents).to.eql([b,a]);
+                // @@
+                expect(parents[0].sameNode(b)).to.be.true;
+                expect(parents[1].sameNode(a)).to.be.true;
             });
         });
 
             });
         });
 
@@ -939,6 +941,57 @@ describe('smartxml', function() {
             expect(textNode.textTestTransformation().sameNode(textNode)).to.be.true;
             expect(textNode.elementTestTransfomation).to.be.undefined; 
         });
             expect(textNode.textTestTransformation().sameNode(textNode)).to.be.true;
             expect(textNode.elementTestTransfomation).to.be.undefined; 
         });
+
+        it('allows text/element node methods and transformations to access node and transormations on document node', function() {
+
+            var doc = getDocumentFromXML('<div>text</div>');
+
+            doc.registerExtension({
+                documentNode: {
+                    methods: {
+                        test: function() {
+                            return 'super';
+                        }
+                    },
+                    transformations: {
+                        testT: function() {
+                            return 'super_trans';
+                        }
+                    }
+                },
+                elementNode: {
+                    methods: {
+                        test: function() {
+                            return 'element_sub_' + this.__super__.test();
+                        }
+                    },
+                    transformations: {
+                        testT: function() {
+                            return 'element_trans_sub_' + this.__super__.testT();
+                        }
+                    }
+                },
+                textNode: {
+                    methods: {
+                        test: function() {
+                            return 'text_sub_' + this.__super__.test();
+                        }
+                    },
+                    transformations: {
+                        testT: function() {
+                            return 'text_trans_sub_' + this.__super__.testT();
+                        }
+                    }
+                }
+            });
+
+            var textNode = doc.root.contents()[0];
+
+            expect(doc.root.test()).to.equal('element_sub_super');
+            expect(textNode.test()).to.equal('text_sub_super');
+            expect(doc.root.testT()).to.equal('element_trans_sub_super_trans');
+            expect(textNode.testT()).to.equal('text_trans_sub_super_trans');
+        });
     });
 
     // describe('Undo/redo', function() {
     });
 
     // describe('Undo/redo', function() {