diff --git a/src/dom_components/main.js b/src/dom_components/main.js index 0f1ea6600..2c60bd031 100644 --- a/src/dom_components/main.js +++ b/src/dom_components/main.js @@ -70,6 +70,8 @@ define(function(require) { return { + componentTypes: defaultTypes, + /** * Name of the module * @type {String} diff --git a/test/specs/code_manager/model/CodeModels.js b/test/specs/code_manager/model/CodeModels.js index c1dd10353..9ce02e874 100644 --- a/test/specs/code_manager/model/CodeModels.js +++ b/test/specs/code_manager/model/CodeModels.js @@ -1,15 +1,22 @@ var path = 'CodeManager/model/'; define([path + 'HtmlGenerator', path + 'CssGenerator', + 'DomComponents', 'DomComponents/model/Component', 'CssComposer'], - function(HtmlGenerator, CssGenerator, Component, CssComposer) { + function(HtmlGenerator, CssGenerator, DomComponents, Component, CssComposer) { return { run : function(){ + var comp; + describe('HtmlGenerator', function() { beforeEach(function () { - this.obj = new HtmlGenerator(); + this.obj = new HtmlGenerator(); + var dcomp = new DomComponents(); + comp = new Component({}, { + defaultTypes: dcomp.componentTypes, + }); }); afterEach(function () { @@ -17,18 +24,15 @@ define([path + 'HtmlGenerator', }); it('Build correctly one component', function() { - var comp = new Component(); this.obj.build(comp).should.equal(''); }); it('Build correctly empty component inside', function() { - var comp = new Component(); var m1 = comp.get('components').add({}); this.obj.build(comp).should.equal('
'); }); it('Build correctly not empty component inside', function() { - var comp = new Component(); var m1 = comp.get('components').add({ tagName: 'article', attributes: { @@ -40,7 +44,6 @@ define([path + 'HtmlGenerator', }); it('Build correctly component with classes', function() { - var comp = new Component(); var m1 = comp.get('components').add({ tagName: 'article', attributes: { @@ -56,11 +59,15 @@ define([path + 'HtmlGenerator', }); describe('CssGenerator', function() { - var newCssComp = function(){ - return new CssComposer().init(); - }; - beforeEach(function () { + var newCssComp = function(){ + return new CssComposer().init(); + }; + beforeEach(function () { this.obj = new CssGenerator(); + var dcomp = new DomComponents(); + comp = new Component({}, { + defaultTypes: dcomp.componentTypes, + }); }); afterEach(function () { @@ -68,18 +75,15 @@ define([path + 'HtmlGenerator', }); it('Build correctly one component', function() { - var comp = new Component(); this.obj.build(comp).should.equal(''); }); it('Build correctly empty component inside', function() { - var comp = new Component(); var m1 = comp.get('components').add({tagName: 'article'}); this.obj.build(comp).should.equal(''); }); it('Build correctly component with style inside', function() { - var comp = new Component(); var m1 = comp.get('components').add({ tagName: 'article', style: { @@ -91,7 +95,6 @@ define([path + 'HtmlGenerator', }); it('Build correctly component with class styled', function() { - var comp = new Component(); var m1 = comp.get('components').add({tagName: 'article'}); var cls1 = m1.get('classes').add({name: 'class1'}); @@ -103,7 +106,6 @@ define([path + 'HtmlGenerator', }); it('Build correctly component styled with class and state', function() { - var comp = new Component(); var m1 = comp.get('components').add({tagName: 'article'}); var cls1 = m1.get('classes').add({name: 'class1'}); @@ -117,7 +119,6 @@ define([path + 'HtmlGenerator', it('Build correctly with more classes', function() { - var comp = new Component(); var m1 = comp.get('components').add({tagName: 'article'}); var cls1 = m1.get('classes').add({name: 'class1'}); var cls2 = m1.get('classes').add({name: 'class2'}); @@ -131,7 +132,6 @@ define([path + 'HtmlGenerator', }); it('Build correctly with class styled out', function() { - var comp = new Component(); var m1 = comp.get('components').add({tagName: 'article'}); var cls1 = m1.get('classes').add({name: 'class1'}); var cls2 = m1.get('classes').add({name: 'class2'}); @@ -146,7 +146,6 @@ define([path + 'HtmlGenerator', }); it('Rule with media query', function() { - var comp = new Component(); var m1 = comp.get('components').add({tagName: 'article'}); var cls1 = m1.get('classes').add({name: 'class1'}); var cls2 = m1.get('classes').add({name: 'class2'}); @@ -160,7 +159,6 @@ define([path + 'HtmlGenerator', }); it('Rules mixed with media queries', function() { - var comp = new Component(); var m1 = comp.get('components').add({tagName: 'article'}); var cls1 = m1.get('classes').add({name: 'class1'}); var cls2 = m1.get('classes').add({name: 'class2'}); @@ -186,7 +184,6 @@ define([path + 'HtmlGenerator', }); it("Avoid useless code", function() { - var comp = new Component(); var m1 = comp.get('components').add({tagName: 'article'}); var cls1 = m1.get('classes').add({name: 'class1'}); @@ -201,4 +198,4 @@ define([path + 'HtmlGenerator', } }; -}); \ No newline at end of file +}); diff --git a/test/specs/dom_components/model/Component.js b/test/specs/dom_components/model/Component.js index 22fee3bb4..0ab172687 100644 --- a/test/specs/dom_components/model/Component.js +++ b/test/specs/dom_components/model/Component.js @@ -1,17 +1,24 @@ -define(['DomComponents/model/Component', +define(['DomComponents', + 'DomComponents/model/Component', 'DomComponents/model/ComponentImage', 'DomComponents/model/ComponentText', 'DomComponents/model/Components'], - function(Component, ComponentImage, ComponentText, Components) { + function(DomComponents, Component, ComponentImage, ComponentText, Components) { return { run : function(){ var obj; + var dcomp; + var compOpts; describe('Component', function() { beforeEach(function () { obj = new Component(); + dcomp = new DomComponents(); + compOpts = { + defaultTypes: dcomp.componentTypes, + }; }); afterEach(function () { @@ -79,13 +86,13 @@ define(['DomComponents/model/Component', }); it('Component toHTML with children', function() { - obj = new Component({tagName: 'article'}); + obj = new Component({tagName: 'article'}, compOpts); obj.get('components').add({tagName: 'span'}); obj.toHTML().should.equal('