linting, cleanup, removing unused code
[fnpeditor.git] / src / wlxml / wlxml.test.js
index c802ae3..9f846f6 100644 (file)
@@ -6,7 +6,7 @@ define([
 'use strict';
 
 /* jshint expr:true */
-/* global it, describe */
+/* global it, describe, beforeEach */
 
 var expect = chai.expect;
 
@@ -103,6 +103,8 @@ describe('WLXMLDocument', function() {
     });
 
     describe('White space handling', function() {
+        /* globals Node */
+
         it('ignores white space surrounding block elements', function() {
             var node = nodeFromXML('<section> <div></div> </section>'),
                 contents = node.contents();
@@ -251,6 +253,43 @@ describe('WLXMLDocument', function() {
 
     });
 
+    describe('Extension', function() {
+        var doc, extension, elementNode, textNode, testClassNode;
+
+        beforeEach(function() {
+            doc = getDocumentFromXML('<section>Alice<div class="test_class"></div></section>');
+            elementNode = doc.root;
+            textNode = doc.root.contents()[0];
+            testClassNode = doc.root.contents('.test_class');
+            extension = {};
+            
+            expect(testClassNode.object).to.be.undefined;
+
+        });
+
+        it('allows adding method to an ElementNode of specific class', function() {
+            extension = {wlxmlClass: {test_class: {methods: {
+                testMethod: function() { return this; }
+            }}}};
+            doc.registerExtension(extension);
+            testClassNode = doc.root.contents()[1];
+            expect(testClassNode.object.testMethod().sameNode(testClassNode)).to.equal(true, '1');
+        });
+
+        it('allows adding transformation to an ElementNode of specific class', function() {
+            extension = {wlxmlClass: {test_class: {transformations: {
+                testTransformation: function() { return this; },
+                testTransformation2: {impl: function() { return this; }}
+            }}}};
+            doc.registerExtension(extension);
+            testClassNode = doc.root.contents()[1];
+            expect(testClassNode.object.testTransformation().sameNode(testClassNode)).to.equal(true, '1');
+            expect(testClassNode.object.testTransformation2().sameNode(testClassNode)).to.equal(true, '1');
+        });
+
+
+    });
+
 });
 
 });
\ No newline at end of file