diff --git a/test/main.js b/test/main.js
index a6d66bdfc..58de82bc3 100644
--- a/test/main.js
+++ b/test/main.js
@@ -23,4 +23,5 @@ describe('Main', () => {
require(`${path}plugin_manager`);
require(`${path}selector_manager`);
require(`${path}storage_manager`);
+ require(`${path}style_manager`);
});
diff --git a/test/specs/style_manager/index.js b/test/specs/style_manager/index.js
new file mode 100644
index 000000000..db255ddcd
--- /dev/null
+++ b/test/specs/style_manager/index.js
@@ -0,0 +1,192 @@
+const StyleManager = require('style_manager');
+const Models = require('./model/Models');
+const SectorView = require('./view/SectorView');
+const SectorsView = require('./view/SectorsView');
+const PropertyView = require('./view/PropertyView');
+const PropertySelectView = require('./view/PropertySelectView');
+const PropertyRadioView = require('./view/PropertyRadioView');
+const PropertyIntegerView = require('./view/PropertyIntegerView');
+const PropertyColorView = require('./view/PropertyColorView');
+const PropertyCompositeView = require('./view/PropertyCompositeView');
+const PropertyStackView = require('./view/PropertyStackView');
+const LayerView = require('./view/LayerView');
+
+describe.only('StyleManager', function() {
+
+ describe('Main', function() {
+
+ var obj;
+
+ beforeEach(function () {
+ obj = new StyleManager().init({
+ sectors: []
+ });
+ });
+
+ afterEach(function () {
+ obj = null;
+ });
+
+ it('Object exists', function() {
+ obj.should.be.ok;
+ });
+
+ it('No sectors', function() {
+ obj.getSectors().length.should.equal(0);
+ });
+
+ it('Add sector', function() {
+ obj.addSector('test', {
+ name: 'Test name'
+ });
+ obj.getSectors().length.should.equal(1);
+ var sector = obj.getSectors().at(0);
+ sector.get('id').should.equal('test');
+ sector.get('name').should.equal('Test name');
+ });
+
+ it('Add sectors', function() {
+ obj.addSector('test', {});
+ obj.addSector('test2', {});
+ obj.getSectors().length.should.equal(2);
+ });
+
+ it("Can't create more than one sector with the same id", function() {
+ var sect1 = obj.addSector('test', {});
+ var sect2 = obj.addSector('test', {});
+ obj.getSectors().length.should.equal(1);
+ sect1.should.deep.equal(sect2);
+ });
+
+ it('Get inexistent sector', function() {
+ (obj.getSector('test') == null).should.equal(true);
+ });
+
+ it('Get sector', function() {
+ var sect1 = obj.addSector('test', { name: 'Test' });
+ var sect2 = obj.getSector('test');
+ sect1.should.deep.equal(sect2);
+ });
+
+ it('Add property to inexistent sector', function() {
+ (obj.addProperty('test', {}) == null).should.equal(true);
+ });
+
+ it('Add property', function() {
+ obj.addSector('test', {});
+ (obj.addProperty('test', {}) == null).should.equal(false);
+ obj.getProperties('test').length.should.equal(1);
+ });
+
+ it('Check added property', function() {
+ obj.addSector('test', {});
+ var prop = obj.addProperty('test', {
+ 'name': 'test',
+ });
+ prop.get('name').should.equal('test');
+ });
+
+ it('Add properties', function() {
+ obj.addSector('test', {});
+ obj.addProperty('test', [{}, {}]);
+ obj.getProperties('test').length.should.equal(2);
+ });
+
+ it('Get property from inexistent sector', function() {
+ (obj.getProperty('test', 'test-prop') == null).should.equal(true);
+ });
+
+ it("Can't get properties without proper name", function() {
+ obj.addSector('test', {});
+ obj.addProperty('test', [{}, {}]);
+ obj.getProperty('test', 'test-prop').should.be.empty;
+ });
+
+ it("Get property with proper name", function() {
+ obj.addSector('test', {});
+ var prop1 = obj.addProperty('test', {property: 'test-prop'});
+ var prop2 = obj.getProperty('test', 'test-prop');
+ prop1.should.deep.equal(prop2);
+ });
+
+ it("Get properties with proper name", function() {
+ obj.addSector('test', {});
+ var prop1 = obj.addProperty('test',[
+ {property: 'test-prop'},
+ {property: 'test-prop'}
+ ]);
+ obj.getProperty('test', 'test-prop').length.should.equal(2);
+ });
+
+ it('Get inexistent properties', function() {
+ (obj.getProperties('test') == null).should.equal(true);
+ (obj.getProperties() == null).should.equal(true);
+ });
+
+ it('Renders correctly', function() {
+ obj.render().should.be.ok;
+ });
+
+ describe('Init with configuration', function() {
+
+ beforeEach(function () {
+ obj = new StyleManager().init({
+ sectors: [{
+ id: 'dim',
+ name: 'Dimension',
+ properties: [{
+ name: 'Width',
+ property: 'width',
+ },{
+ name: 'Height',
+ property: 'height',
+ }],
+ },{
+ id: 'pos',
+ name: 'position',
+ properties: [{
+ name: 'Width',
+ property: 'width',
+ }],
+ }],
+ });
+ });
+
+ afterEach(function () {
+ obj = null;
+ });
+
+ it('Sectors added', function() {
+ obj.getSectors().length.should.equal(2);
+ var sect1 = obj.getSector('dim');
+ sect1.get('name').should.equal('Dimension');
+ });
+
+ it('Properties added', function() {
+ var sect1 = obj.getSector('dim');
+ var sect2 = obj.getSector('pos');
+ sect1.get('properties').length.should.equal(2);
+ sect2.get('properties').length.should.equal(1);
+ });
+
+ it('Property is correct', function() {
+ var prop1 = obj.getProperty('dim', 'width');
+ prop1.get('name').should.equal('Width');
+ });
+
+ });
+
+ Models.run();
+ SectorView.run();
+ SectorsView.run();
+ PropertyView.run();
+ PropertySelectView.run();
+ PropertyRadioView.run();
+ PropertyIntegerView.run();
+ PropertyColorView.run();
+ PropertyCompositeView.run();
+ PropertyStackView.run();
+ LayerView.run();
+ });
+
+});
diff --git a/test/specs/style_manager/main.js b/test/specs/style_manager/main.js
deleted file mode 100644
index 275f3fa5e..000000000
--- a/test/specs/style_manager/main.js
+++ /dev/null
@@ -1,185 +0,0 @@
-define(function(require, exports, module){
- 'use strict';
- var StyleManager = require('StyleManager');
- var LayerView = require('undefined');
-
- describe('StyleManager', function() {
-
- describe('Main', function() {
-
- var obj;
-
- beforeEach(function () {
- obj = new StyleManager().init({
- sectors: []
- });
- });
-
- afterEach(function () {
- delete obj;
- });
-
- it('Object exists', function() {
- obj.should.be.ok;
- });
-
- it('No sectors', function() {
- obj.getSectors().length.should.equal(0);
- });
-
- it('Add sector', function() {
- obj.addSector('test', {
- name: 'Test name'
- });
- obj.getSectors().length.should.equal(1);
- var sector = obj.getSectors().at(0);
- sector.get('id').should.equal('test');
- sector.get('name').should.equal('Test name');
- });
-
- it('Add sectors', function() {
- obj.addSector('test', {});
- obj.addSector('test2', {});
- obj.getSectors().length.should.equal(2);
- });
-
- it("Can't create more than one sector with the same id", function() {
- var sect1 = obj.addSector('test', {});
- var sect2 = obj.addSector('test', {});
- obj.getSectors().length.should.equal(1);
- sect1.should.deep.equal(sect2);
- });
-
- it('Get inexistent sector', function() {
- (obj.getSector('test') == null).should.equal(true);
- });
-
- it('Get sector', function() {
- var sect1 = obj.addSector('test', { name: 'Test' });
- var sect2 = obj.getSector('test');
- sect1.should.deep.equal(sect2);
- });
-
- it('Add property to inexistent sector', function() {
- (obj.addProperty('test', {}) == null).should.equal(true);
- });
-
- it('Add property', function() {
- obj.addSector('test', {});
- (obj.addProperty('test', {}) == null).should.equal(false);
- obj.getProperties('test').length.should.equal(1);
- });
-
- it('Check added property', function() {
- obj.addSector('test', {});
- var prop = obj.addProperty('test', {
- 'name': 'test',
- });
- prop.get('name').should.equal('test');
- });
-
- it('Add properties', function() {
- obj.addSector('test', {});
- obj.addProperty('test', [{}, {}]);
- obj.getProperties('test').length.should.equal(2);
- });
-
- it('Get property from inexistent sector', function() {
- (obj.getProperty('test', 'test-prop') == null).should.equal(true);
- });
-
- it("Can't get properties without proper name", function() {
- obj.addSector('test', {});
- obj.addProperty('test', [{}, {}]);
- obj.getProperty('test', 'test-prop').should.be.empty;
- });
-
- it("Get property with proper name", function() {
- obj.addSector('test', {});
- var prop1 = obj.addProperty('test', {property: 'test-prop'});
- var prop2 = obj.getProperty('test', 'test-prop');
- prop1.should.deep.equal(prop2);
- });
-
- it("Get properties with proper name", function() {
- obj.addSector('test', {});
- var prop1 = obj.addProperty('test',[
- {property: 'test-prop'},
- {property: 'test-prop'}
- ]);
- obj.getProperty('test', 'test-prop').length.should.equal(2);
- });
-
- it('Get inexistent properties', function() {
- (obj.getProperties('test') == null).should.equal(true);
- (obj.getProperties() == null).should.equal(true);
- });
-
- it('Renders correctly', function() {
- obj.render().should.be.ok;
- });
-
- describe('Init with configuration', function() {
-
- beforeEach(function () {
- obj = new StyleManager().init({
- sectors: [{
- id: 'dim',
- name: 'Dimension',
- properties: [{
- name: 'Width',
- property: 'width',
- },{
- name: 'Height',
- property: 'height',
- }],
- },{
- id: 'pos',
- name: 'position',
- properties: [{
- name: 'Width',
- property: 'width',
- }],
- }],
- });
- });
-
- afterEach(function () {
- delete obj;
- });
-
- it('Sectors added', function() {
- obj.getSectors().length.should.equal(2);
- var sect1 = obj.getSector('dim');
- sect1.get('name').should.equal('Dimension');
- });
-
- it('Properties added', function() {
- var sect1 = obj.getSector('dim');
- var sect2 = obj.getSector('pos');
- sect1.get('properties').length.should.equal(2);
- sect2.get('properties').length.should.equal(1);
- });
-
- it('Property is correct', function() {
- var prop1 = obj.getProperty('dim', 'width');
- prop1.get('name').should.equal('Width');
- });
-
- });
-
- Models.run();
- SectorView.run();
- SectorsView.run();
- PropertyView.run();
- PropertySelectView.run();
- PropertyRadioView.run();
- PropertyIntegerView.run();
- PropertyColorView.run();
- PropertyCompositeView.run();
- PropertyStackView.run();
- LayerView.run();
- });
-
- });
-});
\ No newline at end of file
diff --git a/test/specs/style_manager/model/Models.js b/test/specs/style_manager/model/Models.js
index f3c8f2beb..4f88971e8 100644
--- a/test/specs/style_manager/model/Models.js
+++ b/test/specs/style_manager/model/Models.js
@@ -1,827 +1,823 @@
-define(function(require, exports, module){
- 'use strict';
- var Layers = require('undefined');
-
- module.exports = {
- run : function(){
-
- describe('Sector', function() {
-
- var obj;
- var confToExt;
-
- beforeEach(function () {
- confToExt = {
- buildProps: ['display', 'float'],
- properties: [{
- property: 'display',
- type: 'radio',
- },{
- property: 'color',
- type: 'color',
- }]
- };
- obj = new Sector();
- });
-
- afterEach(function () {
- delete obj;
- });
-
- it('Has id property', function() {
- obj.has('id').should.equal(true);
- });
-
- it('Has no properties', function() {
- obj.get('properties').length.should.equal(0);
- });
-
- it('Init with properties', function() {
- obj = new Sector({
- properties: [{}, {}]
- });
- obj.get('properties').length.should.equal(2);
- });
-
- it('Build properties', function() {
- var res = obj.buildProperties(['display', 'float']);
- res.length.should.equal(2);
- res[0].should.deep.equal({
- property: 'display',
- type: 'select',
- defaults: 'block',
- list: [
- {value: 'block'},
- {value: 'inline'},
- {value: 'inline-block'},
- {value: 'none'},
- ],
- });
- });
-
- it('Extend properties', function() {
- obj = new Sector(confToExt);
- obj.get('properties').length.should.equal(3);
- var prop0 = obj.get('properties').at(0);
- prop0.get('type').should.equal('radio');
- prop0.get('defaults').should.equal('block');
- });
-
- it('Do not extend properties', function() {
- confToExt.extendBuilded = 0;
- obj = new Sector(confToExt);
- obj.get('properties').length.should.equal(3);
- var prop0 = obj.get('properties').at(0);
- prop0.get('type').should.equal('radio');
- prop0.get('defaults').should.equal('');
- });
-
- it('Extend composed properties', function() {
- obj = new Sector({
- buildProps: ['margin', 'float'],
- properties: [{
- property: 'margin',
- properties:[{
- name: 'Top',
- property: 'margin-top',
- },{
- property: 'margin-right',
- }]
- }]
- });
- var sectProps = obj.get('properties');
- sectProps.length.should.equal(2);
- var prop0 = obj.get('properties').at(0);
- var propProps = prop0.get('properties');
-
- propProps.length.should.equal(2);
- var propTop = propProps.at(0);
- propTop.get('name').should.equal('Top');
- propTop.get('type').should.equal('integer');
- });
-
+const Layers = require('style_manager/model/Layers');
+
+module.exports = {
+ run : function(){
+
+ describe.only('Sector', function() {
+
+ var obj;
+ var confToExt;
+
+ beforeEach(function () {
+ confToExt = {
+ buildProps: ['display', 'float'],
+ properties: [{
+ property: 'display',
+ type: 'radio',
+ },{
+ property: 'color',
+ type: 'color',
+ }]
+ };
+ obj = new Sector();
+ });
+
+ afterEach(function () {
+ obj = null;
+ });
+
+ it('Has id property', function() {
+ obj.has('id').should.equal(true);
+ });
+
+ it('Has no properties', function() {
+ obj.get('properties').length.should.equal(0);
+ });
+
+ it('Init with properties', function() {
+ obj = new Sector({
+ properties: [{}, {}]
});
-
- describe('Sectors', function() {
-
- var obj;
-
- beforeEach(function () {
- obj = new Sectors();
- });
-
- afterEach(function () {
- delete obj;
- });
-
- it('Object exists', function() {
- obj.should.be.ok;
- });
-
+ obj.get('properties').length.should.equal(2);
+ });
+
+ it('Build properties', function() {
+ var res = obj.buildProperties(['display', 'float']);
+ res.length.should.equal(2);
+ res[0].should.deep.equal({
+ property: 'display',
+ type: 'select',
+ defaults: 'block',
+ list: [
+ {value: 'block'},
+ {value: 'inline'},
+ {value: 'inline-block'},
+ {value: 'none'},
+ ],
});
+ });
+
+ it('Extend properties', function() {
+ obj = new Sector(confToExt);
+ obj.get('properties').length.should.equal(3);
+ var prop0 = obj.get('properties').at(0);
+ prop0.get('type').should.equal('radio');
+ prop0.get('defaults').should.equal('block');
+ });
+
+ it('Do not extend properties', function() {
+ confToExt.extendBuilded = 0;
+ obj = new Sector(confToExt);
+ obj.get('properties').length.should.equal(3);
+ var prop0 = obj.get('properties').at(0);
+ prop0.get('type').should.equal('radio');
+ prop0.get('defaults').should.equal('');
+ });
+
+ it('Extend composed properties', function() {
+ obj = new Sector({
+ buildProps: ['margin', 'float'],
+ properties: [{
+ property: 'margin',
+ properties:[{
+ name: 'Top',
+ property: 'margin-top',
+ },{
+ property: 'margin-right',
+ }]
+ }]
+ });
+ var sectProps = obj.get('properties');
+ sectProps.length.should.equal(2);
+ var prop0 = obj.get('properties').at(0);
+ var propProps = prop0.get('properties');
- describe('Property', function() {
-
- var obj;
-
- beforeEach(function () {
- obj = new Property();
- });
-
- afterEach(function () {
- delete obj;
- });
-
- it('Has property field', function() {
- obj.has('property').should.equal(true);
- });
+ propProps.length.should.equal(2);
+ var propTop = propProps.at(0);
+ propTop.get('name').should.equal('Top');
+ propTop.get('type').should.equal('integer');
+ });
- it('Has no properties', function() {
- obj.get('properties').length.should.equal(0);
- });
+ });
- it('Has no layers', function() {
- obj.get('layers').length.should.equal(0);
- });
+ describe('Sectors', function() {
- });
+ var obj;
- describe('Properties', function() {
+ beforeEach(function () {
+ obj = new Sectors();
+ });
- var obj;
+ afterEach(function () {
+ obj = null;
+ });
- beforeEach(function () {
- obj = new Properties();
- });
+ it('Object exists', function() {
+ obj.should.be.ok;
+ });
- afterEach(function () {
- delete obj;
- });
+ });
- it('Object exists', function() {
- obj.should.be.ok;
- });
+ describe('Property', function() {
- });
+ var obj;
- describe('Layer', function() {
+ beforeEach(function () {
+ obj = new Property();
+ });
- var obj;
+ afterEach(function () {
+ obj = null;
+ });
- beforeEach(function () {
- obj = new Layer();
- });
+ it('Has property field', function() {
+ obj.has('property').should.equal(true);
+ });
- afterEach(function () {
- delete obj;
- });
+ it('Has no properties', function() {
+ obj.get('properties').length.should.equal(0);
+ });
- it('Has index property', function() {
- obj.has('index').should.equal(true);
- });
+ it('Has no layers', function() {
+ obj.get('layers').length.should.equal(0);
+ });
- it('Is active', function() {
- obj.get('active').should.equal(true);
- });
+ });
- });
+ describe('Properties', function() {
- describe('Layers', function() {
+ var obj;
- var obj;
+ beforeEach(function () {
+ obj = new Properties();
+ });
- beforeEach(function () {
- obj = new Layers();
- });
+ afterEach(function () {
+ obj = null;
+ });
- afterEach(function () {
- delete obj;
- });
+ it('Object exists', function() {
+ obj.should.be.ok;
+ });
- it('Object exists', function() {
- obj.should.be.ok;
- });
+ });
- it('Init index on add', function() {
- var model = obj.add({});
- model.get('index').should.equal(1);
- });
+ describe('Layer', function() {
- it('Increment index', function() {
- var model = obj.add({});
- var model2 = obj.add({});
- model2.get('index').should.equal(2);
- });
+ var obj;
- it('Cache index', function() {
- var model = obj.add({});
- var model2 = obj.add({});
- obj.remove(model2);
- var model3 = obj.add({});
- model3.get('index').should.equal(3);
- });
+ beforeEach(function () {
+ obj = new Layer();
+ });
- it('Reset index on reset', function() {
- var model = obj.add({});
- var model2 = obj.add({});
- obj.reset();
- obj.idx.should.equal(1);
- });
+ afterEach(function () {
+ obj = null;
+ });
- });
-
- describe('PropertyFactory', function() {
-
- var obj;
-
- beforeEach(function () {
- obj = new PropertyFactory();
- });
-
- afterEach(function () {
- delete obj;
- });
-
- it('Object exists', function() {
- obj.should.be.ok;
- });
-
- it('Build single prop', function() {
- obj.build('float').should.deep.equal([{
- property: 'float',
- type: 'radio',
- defaults: 'none',
- list: [
- {value: 'none'},
- {value: 'left'},
- {value: 'right'},
- ],
- }]);
- });
-
- it('Build display', function() {
- obj.build('display').should.deep.equal([{
- property: 'display',
- type: 'select',
- defaults: 'block',
- list: [
- {value: 'block'},
- {value: 'inline'},
- {value: 'inline-block'},
- {value: 'none'},
- ],
- }]);
- });
-
- it('Build position', function() {
- obj.build('position').should.deep.equal([{
- property: 'position',
- type: 'radio',
- defaults: 'static',
- list: [
- {value: 'static'},
- {value: 'relative'},
- {value: 'absolute'},
- {value: 'fixed'},
- ],
- }]);
- });
-
- it('Build top, left, right, bottom', function() {
- var res = {
- type: 'integer',
- units: ['px','%'],
- defaults : 0,
- }
- res.property = 'top';
- obj.build('top').should.deep.equal([res]);
- res.property = 'right';
- obj.build('right').should.deep.equal([res]);
- res.property = 'bottom';
- obj.build('bottom').should.deep.equal([res]);
- res.property = 'left';
- obj.build('left').should.deep.equal([res]);
- });
-
- it('Build width and height family', function() {
- var res = {
- type: 'integer',
- units: ['px','%'],
- defaults: 'auto',
- fixedValues: ['initial', 'inherit', 'auto'],
- min: 0,
- }
- res.property = 'width';
- obj.build('width').should.deep.equal([res]);
- res.property = 'height';
- obj.build('height').should.deep.equal([res]);
- res.property = 'min-height';
- obj.build('min-height').should.deep.equal([res]);
- res.property = 'max-height';
- obj.build('max-height').should.deep.equal([res]);
- res.property = 'min-width';
- obj.build('min-width').should.deep.equal([res]);
- res.property = 'max-width';
- obj.build('max-width').should.deep.equal([res]);
- });
-
- it('Build margin', function() {
- var res = {
- property: 'margin',
- type: 'composite',
- properties:[{
- fixedValues: ['initial', 'inherit', 'auto'],
- property : 'margin-top',
- type : 'integer',
- units : ['px','%'],
- defaults : 0
- },{
- fixedValues: ['initial', 'inherit', 'auto'],
- property : 'margin-right',
- type : 'integer',
- units : ['px','%'],
- defaults : 0,
- },{
- fixedValues: ['initial', 'inherit', 'auto'],
- property : 'margin-bottom',
- type : 'integer',
- units : ['px','%'],
- defaults : 0,
- },{
- fixedValues: ['initial', 'inherit', 'auto'],
- property : 'margin-left',
- type : 'integer',
- units : ['px','%'],
- defaults : 0,
- },],
- };
- obj.build('margin').should.deep.equal([res]);
- });
-
- it('Build padding', function() {
- var res = {
- property: 'padding',
- type: 'composite',
- properties:[{
- property : 'padding-top',
- fixedValues: ['initial', 'inherit', 'auto'],
- type : 'integer',
- units : ['px','%'],
- defaults : 0,
- },{
- property : 'padding-right',
- fixedValues: ['initial', 'inherit', 'auto'],
- type : 'integer',
- units : ['px','%'],
- defaults : 0,
- },{
- property : 'padding-bottom',
- fixedValues: ['initial', 'inherit', 'auto'],
- type : 'integer',
- units : ['px','%'],
- defaults : 0,
- },{
- property : 'padding-left',
- fixedValues: ['initial', 'inherit', 'auto'],
- type : 'integer',
- units : ['px','%'],
- defaults : 0,
- },],
- };
- obj.build('padding').should.deep.equal([res]);
- });
-
- it('Build font-family', function() {
- var ss = ', sans-serif';
- var ms = ', monospace';
- var ff = 'font-family: ';
- var sty = '; font-size:15px';
- var res = {
- property: 'font-family',
- type: 'select',
- defaults: 'Arial, Helvetica' + ss,
- list:[
- {name: 'Arial', value: 'Arial, Helvetica' + ss, style: ff + 'Arial, Helvetica' + ss + sty},
- {name: 'Arial Black', value: 'Arial Black, Gadget' + ss, style: ff + 'Arial Black, Gadget' + ss + sty},
- {name: 'Brush Script MT', value: 'Brush Script MT' + ss, style: ff + 'Brush Script MT' + ss + sty},
- {name: 'Comic Sans MS', value: 'Comic Sans MS, cursive' + ss, style: ff + 'Comic Sans MS, cursive' + ss + sty},
- {name: 'Courier New', value: 'Courier New, Courier' + ms, style: ff + 'Courier New, Courier' + ms + sty},
- {name: 'Georgia', value: 'Georgia, serif', style: ff + 'Georgia, serif' + sty},
- {name: 'Helvetica', value: 'Helvetica, serif', style: ff + 'Helvetica, serif' + sty},
- {name: 'Impact', value: 'Impact, Charcoal' + ss, style: ff + 'Impact, Charcoal' + ss + sty},
- {name: 'Lucida Sans Unicode', value: 'Lucida Sans Unicode, Lucida Grande' + ss, style: ff + 'Lucida Sans Unicode, Lucida Grande' + ss + sty},
- {name: 'Tahoma', value: 'Tahoma, Geneva' + ss, style: ff + 'Tahoma, Geneva' + ss + sty},
- {name: 'Times New Roman', value: 'Times New Roman, Times, serif', style: ff + 'Times New Roman, Times, serif' + sty},
- {name: 'Trebuchet MS', value: 'Trebuchet MS, Helvetica' + ss, style: ff + 'Trebuchet MS, Helvetica' + ss + sty},
- {name: 'Verdana', value: 'Verdana, Geneva' + ss, style: ff + 'Verdana, Geneva' + ss + sty},
- ],
- };
- obj.build('font-family').should.deep.equal([res]);
- });
-
- it('Build font-size', function() {
- var res = {
- type: 'integer',
- units: ['px','em', 'rem', '%'],
- defaults: 'medium',
- min: 0,
- };
- res.property = 'font-size';
- obj.build('font-size').should.deep.equal([res]);
- });
+ it('Has index property', function() {
+ obj.has('index').should.equal(true);
+ });
- it('Build letter-spacing', function() {
- var res = {
- type: 'integer',
- units: ['px','em', 'rem', '%'],
- defaults: 'normal',
- };
- res.property = 'letter-spacing';
- obj.build('letter-spacing').should.deep.equal([res]);
- });
-
- it('Build font-weight', function() {
- var res = {
- type: 'select',
- defaults: '400',
- list: [{ value : '100', name : 'Thin', },
- { value : '200', name : 'Extra-Light', },
- { value : '300', name : 'Light', },
- { value : '400', name : 'Normal', },
- { value : '500', name : 'Medium',},
- { value : '600', name : 'Semi-Bold',},
- { value : '700', name : 'Bold', },
- { value : '800', name : 'Extra-Bold',},
- { value : '900', name : 'Ultra-Bold', }],
- };
- res.property = 'font-weight';
- obj.build('font-weight').should.deep.equal([res]);
- });
-
- it('Build color', function() {
- var res = {
- property: 'color',
- type: 'color',
- defaults: 'black',
- };
- obj.build('color').should.deep.equal([res]);
- });
-
- it('Build line-height', function() {
- var res = {
- type: 'integer',
- units: ['px','em', 'rem', '%'],
- defaults: 'normal',
- };
- res.property = 'line-height';
- obj.build('line-height').should.deep.equal([res]);
- });
-
- it('Build text-align', function() {
- var res = {
- type: 'radio',
- defaults: 'left',
- list: [{ value : 'left'},
- { value : 'center'},
- { value : 'right'},
- { value : 'justify'}],
- };
- res.property = 'text-align';
- obj.build('text-align').should.deep.equal([res]);
- });
-
- it('Build text-shadow', function() {
- var res = {
- type: 'stack',
- preview: true,
- properties : [{
- property: 'text-shadow-h',
- type: 'integer',
- units: ['px','%'],
- defaults : 0,
- },{
- property: 'text-shadow-v',
- type: 'integer',
- units: ['px','%'],
- defaults : 0,
- },{
- property: 'text-shadow-blur',
- type: 'integer',
- units: ['px','%'],
- defaults : 0,
- min: 0,
- },{
- property: 'text-shadow-color',
- type: 'color',
- defaults: 'black',
- },],
- };
- res.property = 'text-shadow';
- obj.build('text-shadow').should.deep.equal([res]);
- });
-
- it('Build border-radius-c', function() {
- var res = {
- type: 'integer',
- units: ['px', '%'],
- defaults: 0,
- min: 0,
- };
- res.property = 'border-radius';
- obj.build('border-radius-c').should.deep.equal([res]);
- });
-
- it('Build border-radius', function() {
- var res = {
- property: 'border-radius',
- type: 'composite',
- properties: [{
- property : 'border-top-left-radius',
- type: 'integer',
- units: ['px','%'],
- defaults: 0,
- min: 0,
- },{
- property: 'border-top-right-radius',
- type: 'integer',
- units: ['px','%'],
- min : 0,
- defaults: 0,
- },{
- property: 'border-bottom-left-radius',
- type: 'integer',
- units: ['px','%'],
- min: 0,
- defaults: 0,
- },{
- property: 'border-bottom-right-radius',
- type: 'integer',
- units: ['px','%'],
- min: 0,
- defaults : 0,
- },],
- };
- res.property = 'border-radius';
- obj.build('border-radius').should.deep.equal([res]);
- });
-
- it('Build background-color', function() {
- var res = {
- type : 'color',
- defaults: 'none'
- };
- res.property = 'background-color';
- obj.build('background-color').should.deep.equal([res]);
- });
-
- it('Build border', function() {
- var res = {
- property: 'border',
- type: 'composite',
- properties : [{
- property: 'border-width',
- type: 'integer',
- units: ['px','em'],
- defaults: 'medium',
- min: 0,
- },{
- property: 'border-style',
- type : 'select',
- defaults: 'solid',
- list: [{ value : 'none'},
- { value : 'solid'},
- { value : 'dotted'},
- { value : 'dashed'},
- { value : 'double'},
- { value : 'groove'},
- { value : 'ridge'},
- { value : 'inset'},
- { value : 'outset'},],
- },{
- property: 'border-color',
- type: 'color',
- defaults: 'black',
- }],
- };
- obj.build('border').should.deep.equal([res]);
- });
-
- it('Build box-shadow', function() {
- var res = {
- property: 'box-shadow',
- type: 'stack',
- preview: true,
- properties: [{
- property: 'box-shadow-h',
- type: 'integer',
- units: ['px','%'],
- defaults: 0,
- },{
- property: 'box-shadow-v',
- type: 'integer',
- units: ['px','%'],
- defaults: 0,
- },{
- property: 'box-shadow-blur',
- type: 'integer',
- units: ['px'],
- defaults: 5,
- min: 0,
- },{
- property: 'box-shadow-spread',
- type: 'integer',
- units: ['px'],
- defaults: 0,
- },{
- property: 'box-shadow-color',
- type: 'color',
- defaults: 'black',
- },{
- property: 'box-shadow-type',
- type: 'select',
- defaults: '',
- list: [{value : '', name: 'Outside' },
- {value : 'inset', name: 'Inside' }],
- }],
- };
- obj.build('box-shadow').should.deep.equal([res]);
- });
-
- it('Build background', function() {
- var res = {
- property: 'background',
- type: 'stack',
- preview: true,
- detached: true,
- properties : [{
- property: 'background-image',
- type: 'file',
- functionName: 'url',
- defaults: 'none',
- },{
- property: 'background-repeat',
- type: 'select',
- defaults: 'repeat',
- list: [{ value : 'repeat'},
- { value : 'repeat-x'},
- { value : 'repeat-y'},
- { value : 'no-repeat'}],
- },{
- property: 'background-position',
- type: 'select',
- defaults: 'left top',
- list: [ { value : 'left top',},
- { value : 'left center',},
- { value : 'left bottom',},
- { value : 'right top',},
- { value : 'right center'},
- { value : 'right bottom'},
- { value : 'center top'},
- { value : 'center center'},
- { value : 'center bottom'}
- ]
-
- },{
- property: 'background-attachment',
- type: 'select',
- defaults: 'scroll',
- list: [{ value : 'scroll'},
- { value : 'fixed'},
- { value : 'local'}],
- },{
- property: 'background-size',
- type: 'select',
- defaults: 'auto',
- list: [{ value : 'auto'},
- { value : 'cover'},
- { value : 'contain'}],
- }],
- };
- obj.build('background').should.deep.equal([res]);
- });
-
- it('Build transition', function() {
- var res = {
- property: 'transition',
- type: 'stack',
- properties:[{
- property: 'transition-property',
- type: 'select',
- defaults: 'width',
- list: [{ value: 'all'},
- { value: 'width'},
- { value : 'height'},
- { value : 'background-color'},
- { value : 'transform'},
- { value : 'box-shadow'},
- { value : 'opacity'}],
+ it('Is active', function() {
+ obj.get('active').should.equal(true);
+ });
+
+ });
+
+ describe('Layers', function() {
+
+ var obj;
+
+ beforeEach(function () {
+ obj = new Layers();
+ });
+
+ afterEach(function () {
+ obj = null;
+ });
+
+ it('Object exists', function() {
+ obj.should.be.ok;
+ });
+
+ it('Init index on add', function() {
+ var model = obj.add({});
+ model.get('index').should.equal(1);
+ });
+
+ it('Increment index', function() {
+ var model = obj.add({});
+ var model2 = obj.add({});
+ model2.get('index').should.equal(2);
+ });
+
+ it('Cache index', function() {
+ var model = obj.add({});
+ var model2 = obj.add({});
+ obj.remove(model2);
+ var model3 = obj.add({});
+ model3.get('index').should.equal(3);
+ });
+
+ it('Reset index on reset', function() {
+ var model = obj.add({});
+ var model2 = obj.add({});
+ obj.reset();
+ obj.idx.should.equal(1);
+ });
+
+ });
+
+ describe('PropertyFactory', function() {
+
+ var obj;
+
+ beforeEach(function () {
+ obj = new PropertyFactory();
+ });
+
+ afterEach(function () {
+ obj = null;
+ });
+
+ it('Object exists', function() {
+ obj.should.be.ok;
+ });
+
+ it('Build single prop', function() {
+ obj.build('float').should.deep.equal([{
+ property: 'float',
+ type: 'radio',
+ defaults: 'none',
+ list: [
+ {value: 'none'},
+ {value: 'left'},
+ {value: 'right'},
+ ],
+ }]);
+ });
+
+ it('Build display', function() {
+ obj.build('display').should.deep.equal([{
+ property: 'display',
+ type: 'select',
+ defaults: 'block',
+ list: [
+ {value: 'block'},
+ {value: 'inline'},
+ {value: 'inline-block'},
+ {value: 'none'},
+ ],
+ }]);
+ });
+
+ it('Build position', function() {
+ obj.build('position').should.deep.equal([{
+ property: 'position',
+ type: 'radio',
+ defaults: 'static',
+ list: [
+ {value: 'static'},
+ {value: 'relative'},
+ {value: 'absolute'},
+ {value: 'fixed'},
+ ],
+ }]);
+ });
+
+ it('Build top, left, right, bottom', function() {
+ var res = {
+ type: 'integer',
+ units: ['px','%'],
+ defaults : 0,
+ }
+ res.property = 'top';
+ obj.build('top').should.deep.equal([res]);
+ res.property = 'right';
+ obj.build('right').should.deep.equal([res]);
+ res.property = 'bottom';
+ obj.build('bottom').should.deep.equal([res]);
+ res.property = 'left';
+ obj.build('left').should.deep.equal([res]);
+ });
+
+ it('Build width and height family', function() {
+ var res = {
+ type: 'integer',
+ units: ['px','%'],
+ defaults: 'auto',
+ fixedValues: ['initial', 'inherit', 'auto'],
+ min: 0,
+ }
+ res.property = 'width';
+ obj.build('width').should.deep.equal([res]);
+ res.property = 'height';
+ obj.build('height').should.deep.equal([res]);
+ res.property = 'min-height';
+ obj.build('min-height').should.deep.equal([res]);
+ res.property = 'max-height';
+ obj.build('max-height').should.deep.equal([res]);
+ res.property = 'min-width';
+ obj.build('min-width').should.deep.equal([res]);
+ res.property = 'max-width';
+ obj.build('max-width').should.deep.equal([res]);
+ });
+
+ it('Build margin', function() {
+ var res = {
+ property: 'margin',
+ type: 'composite',
+ properties:[{
+ fixedValues: ['initial', 'inherit', 'auto'],
+ property : 'margin-top',
+ type : 'integer',
+ units : ['px','%'],
+ defaults : 0
+ },{
+ fixedValues: ['initial', 'inherit', 'auto'],
+ property : 'margin-right',
+ type : 'integer',
+ units : ['px','%'],
+ defaults : 0,
+ },{
+ fixedValues: ['initial', 'inherit', 'auto'],
+ property : 'margin-bottom',
+ type : 'integer',
+ units : ['px','%'],
+ defaults : 0,
+ },{
+ fixedValues: ['initial', 'inherit', 'auto'],
+ property : 'margin-left',
+ type : 'integer',
+ units : ['px','%'],
+ defaults : 0,
+ },],
+ };
+ obj.build('margin').should.deep.equal([res]);
+ });
+
+ it('Build padding', function() {
+ var res = {
+ property: 'padding',
+ type: 'composite',
+ properties:[{
+ property : 'padding-top',
+ fixedValues: ['initial', 'inherit', 'auto'],
+ type : 'integer',
+ units : ['px','%'],
+ defaults : 0,
+ },{
+ property : 'padding-right',
+ fixedValues: ['initial', 'inherit', 'auto'],
+ type : 'integer',
+ units : ['px','%'],
+ defaults : 0,
+ },{
+ property : 'padding-bottom',
+ fixedValues: ['initial', 'inherit', 'auto'],
+ type : 'integer',
+ units : ['px','%'],
+ defaults : 0,
+ },{
+ property : 'padding-left',
+ fixedValues: ['initial', 'inherit', 'auto'],
+ type : 'integer',
+ units : ['px','%'],
+ defaults : 0,
+ },],
+ };
+ obj.build('padding').should.deep.equal([res]);
+ });
+
+ it('Build font-family', function() {
+ var ss = ', sans-serif';
+ var ms = ', monospace';
+ var ff = 'font-family: ';
+ var sty = '; font-size:15px';
+ var res = {
+ property: 'font-family',
+ type: 'select',
+ defaults: 'Arial, Helvetica' + ss,
+ list:[
+ {name: 'Arial', value: 'Arial, Helvetica' + ss, style: ff + 'Arial, Helvetica' + ss + sty},
+ {name: 'Arial Black', value: 'Arial Black, Gadget' + ss, style: ff + 'Arial Black, Gadget' + ss + sty},
+ {name: 'Brush Script MT', value: 'Brush Script MT' + ss, style: ff + 'Brush Script MT' + ss + sty},
+ {name: 'Comic Sans MS', value: 'Comic Sans MS, cursive' + ss, style: ff + 'Comic Sans MS, cursive' + ss + sty},
+ {name: 'Courier New', value: 'Courier New, Courier' + ms, style: ff + 'Courier New, Courier' + ms + sty},
+ {name: 'Georgia', value: 'Georgia, serif', style: ff + 'Georgia, serif' + sty},
+ {name: 'Helvetica', value: 'Helvetica, serif', style: ff + 'Helvetica, serif' + sty},
+ {name: 'Impact', value: 'Impact, Charcoal' + ss, style: ff + 'Impact, Charcoal' + ss + sty},
+ {name: 'Lucida Sans Unicode', value: 'Lucida Sans Unicode, Lucida Grande' + ss, style: ff + 'Lucida Sans Unicode, Lucida Grande' + ss + sty},
+ {name: 'Tahoma', value: 'Tahoma, Geneva' + ss, style: ff + 'Tahoma, Geneva' + ss + sty},
+ {name: 'Times New Roman', value: 'Times New Roman, Times, serif', style: ff + 'Times New Roman, Times, serif' + sty},
+ {name: 'Trebuchet MS', value: 'Trebuchet MS, Helvetica' + ss, style: ff + 'Trebuchet MS, Helvetica' + ss + sty},
+ {name: 'Verdana', value: 'Verdana, Geneva' + ss, style: ff + 'Verdana, Geneva' + ss + sty},
+ ],
+ };
+ obj.build('font-family').should.deep.equal([res]);
+ });
+
+ it('Build font-size', function() {
+ var res = {
+ type: 'integer',
+ units: ['px','em', 'rem', '%'],
+ defaults: 'medium',
+ min: 0,
+ };
+ res.property = 'font-size';
+ obj.build('font-size').should.deep.equal([res]);
+ });
+
+ it('Build letter-spacing', function() {
+ var res = {
+ type: 'integer',
+ units: ['px','em', 'rem', '%'],
+ defaults: 'normal',
+ };
+ res.property = 'letter-spacing';
+ obj.build('letter-spacing').should.deep.equal([res]);
+ });
+
+ it('Build font-weight', function() {
+ var res = {
+ type: 'select',
+ defaults: '400',
+ list: [{ value : '100', name : 'Thin', },
+ { value : '200', name : 'Extra-Light', },
+ { value : '300', name : 'Light', },
+ { value : '400', name : 'Normal', },
+ { value : '500', name : 'Medium',},
+ { value : '600', name : 'Semi-Bold',},
+ { value : '700', name : 'Bold', },
+ { value : '800', name : 'Extra-Bold',},
+ { value : '900', name : 'Ultra-Bold', }],
+ };
+ res.property = 'font-weight';
+ obj.build('font-weight').should.deep.equal([res]);
+ });
+
+ it('Build color', function() {
+ var res = {
+ property: 'color',
+ type: 'color',
+ defaults: 'black',
+ };
+ obj.build('color').should.deep.equal([res]);
+ });
+
+ it('Build line-height', function() {
+ var res = {
+ type: 'integer',
+ units: ['px','em', 'rem', '%'],
+ defaults: 'normal',
+ };
+ res.property = 'line-height';
+ obj.build('line-height').should.deep.equal([res]);
+ });
+
+ it('Build text-align', function() {
+ var res = {
+ type: 'radio',
+ defaults: 'left',
+ list: [{ value : 'left'},
+ { value : 'center'},
+ { value : 'right'},
+ { value : 'justify'}],
+ };
+ res.property = 'text-align';
+ obj.build('text-align').should.deep.equal([res]);
+ });
+
+ it('Build text-shadow', function() {
+ var res = {
+ type: 'stack',
+ preview: true,
+ properties : [{
+ property: 'text-shadow-h',
+ type: 'integer',
+ units: ['px','%'],
+ defaults : 0,
+ },{
+ property: 'text-shadow-v',
+ type: 'integer',
+ units: ['px','%'],
+ defaults : 0,
+ },{
+ property: 'text-shadow-blur',
+ type: 'integer',
+ units: ['px','%'],
+ defaults : 0,
+ min: 0,
+ },{
+ property: 'text-shadow-color',
+ type: 'color',
+ defaults: 'black',
+ },],
+ };
+ res.property = 'text-shadow';
+ obj.build('text-shadow').should.deep.equal([res]);
+ });
+
+ it('Build border-radius-c', function() {
+ var res = {
+ type: 'integer',
+ units: ['px', '%'],
+ defaults: 0,
+ min: 0,
+ };
+ res.property = 'border-radius';
+ obj.build('border-radius-c').should.deep.equal([res]);
+ });
+
+ it('Build border-radius', function() {
+ var res = {
+ property: 'border-radius',
+ type: 'composite',
+ properties: [{
+ property : 'border-top-left-radius',
+ type: 'integer',
+ units: ['px','%'],
+ defaults: 0,
+ min: 0,
+ },{
+ property: 'border-top-right-radius',
+ type: 'integer',
+ units: ['px','%'],
+ min : 0,
+ defaults: 0,
+ },{
+ property: 'border-bottom-left-radius',
+ type: 'integer',
+ units: ['px','%'],
+ min: 0,
+ defaults: 0,
+ },{
+ property: 'border-bottom-right-radius',
+ type: 'integer',
+ units: ['px','%'],
+ min: 0,
+ defaults : 0,
+ },],
+ };
+ res.property = 'border-radius';
+ obj.build('border-radius').should.deep.equal([res]);
+ });
+
+ it('Build background-color', function() {
+ var res = {
+ type : 'color',
+ defaults: 'none'
+ };
+ res.property = 'background-color';
+ obj.build('background-color').should.deep.equal([res]);
+ });
+
+ it('Build border', function() {
+ var res = {
+ property: 'border',
+ type: 'composite',
+ properties : [{
+ property: 'border-width',
+ type: 'integer',
+ units: ['px','em'],
+ defaults: 'medium',
+ min: 0,
+ },{
+ property: 'border-style',
+ type : 'select',
+ defaults: 'solid',
+ list: [{ value : 'none'},
+ { value : 'solid'},
+ { value : 'dotted'},
+ { value : 'dashed'},
+ { value : 'double'},
+ { value : 'groove'},
+ { value : 'ridge'},
+ { value : 'inset'},
+ { value : 'outset'},],
+ },{
+ property: 'border-color',
+ type: 'color',
+ defaults: 'black',
+ }],
+ };
+ obj.build('border').should.deep.equal([res]);
+ });
+
+ it('Build box-shadow', function() {
+ var res = {
+ property: 'box-shadow',
+ type: 'stack',
+ preview: true,
+ properties: [{
+ property: 'box-shadow-h',
+ type: 'integer',
+ units: ['px','%'],
+ defaults: 0,
+ },{
+ property: 'box-shadow-v',
+ type: 'integer',
+ units: ['px','%'],
+ defaults: 0,
},{
- property: 'transition-duration',
+ property: 'box-shadow-blur',
type: 'integer',
- units: ['s'],
- defaults: '2',
+ units: ['px'],
+ defaults: 5,
min: 0,
},{
- property: 'transition-timing-function',
+ property: 'box-shadow-spread',
+ type: 'integer',
+ units: ['px'],
+ defaults: 0,
+ },{
+ property: 'box-shadow-color',
+ type: 'color',
+ defaults: 'black',
+ },{
+ property: 'box-shadow-type',
type: 'select',
- defaults: 'ease',
- list: [{ value : 'linear'},
- { value : 'ease'},
- { value : 'ease-in'},
- { value : 'ease-out'},
- { value : 'ease-in-out'}],
+ defaults: '',
+ list: [{value : '', name: 'Outside' },
+ {value : 'inset', name: 'Inside' }],
}],
- };
- obj.build('transition').should.deep.equal([res]);
- });
+ };
+ obj.build('box-shadow').should.deep.equal([res]);
+ });
+
+ it('Build background', function() {
+ var res = {
+ property: 'background',
+ type: 'stack',
+ preview: true,
+ detached: true,
+ properties : [{
+ property: 'background-image',
+ type: 'file',
+ functionName: 'url',
+ defaults: 'none',
+ },{
+ property: 'background-repeat',
+ type: 'select',
+ defaults: 'repeat',
+ list: [{ value : 'repeat'},
+ { value : 'repeat-x'},
+ { value : 'repeat-y'},
+ { value : 'no-repeat'}],
+ },{
+ property: 'background-position',
+ type: 'select',
+ defaults: 'left top',
+ list: [ { value : 'left top',},
+ { value : 'left center',},
+ { value : 'left bottom',},
+ { value : 'right top',},
+ { value : 'right center'},
+ { value : 'right bottom'},
+ { value : 'center top'},
+ { value : 'center center'},
+ { value : 'center bottom'}
+ ]
- it('Build perspective', function() {
- var res = {
- property: 'perspective',
+ },{
+ property: 'background-attachment',
+ type: 'select',
+ defaults: 'scroll',
+ list: [{ value : 'scroll'},
+ { value : 'fixed'},
+ { value : 'local'}],
+ },{
+ property: 'background-size',
+ type: 'select',
+ defaults: 'auto',
+ list: [{ value : 'auto'},
+ { value : 'cover'},
+ { value : 'contain'}],
+ }],
+ };
+ obj.build('background').should.deep.equal([res]);
+ });
+
+ it('Build transition', function() {
+ var res = {
+ property: 'transition',
+ type: 'stack',
+ properties:[{
+ property: 'transition-property',
+ type: 'select',
+ defaults: 'width',
+ list: [{ value: 'all'},
+ { value: 'width'},
+ { value : 'height'},
+ { value : 'background-color'},
+ { value : 'transform'},
+ { value : 'box-shadow'},
+ { value : 'opacity'}],
+ },{
+ property: 'transition-duration',
type: 'integer',
- units: ['px'],
- defaults : 0,
+ units: ['s'],
+ defaults: '2',
min: 0,
- };
- obj.build('perspective').should.deep.equal([res]);
- });
-
- it('Build transform', function() {
- var res = {
- property: 'transform',
- type: 'composite',
- properties:[{
- property: 'transform-rotate-x',
- type: 'integer',
- units: ['deg'],
- defaults : 0,
- functionName: 'rotateX',
- },{
- property: 'transform-rotate-y',
- type: 'integer',
- units: ['deg'],
- defaults : 0,
- functionName: 'rotateY',
- },{
- property: 'transform-rotate-z',
- type: 'integer',
- units: ['deg'],
- defaults : 0,
- functionName: 'rotateZ',
- },{
- property: 'transform-scale-x',
- type: 'integer',
- defaults : 1,
- functionName: 'scaleX',
- },{
- property: 'transform-scale-y',
- type: 'integer',
- defaults : 1,
- functionName: 'scaleY',
- },{
- property: 'transform-scale-z',
- type: 'integer',
- defaults : 1,
- functionName: 'scaleZ',
- }],
- };
- obj.build('transform').should.deep.equal([res]);
- });
-
- it('Build cursor', function() {
- var res = {
- type: 'select',
- property: 'cursor',
- defaults: 'auto',
- list: [{ value : 'auto'},
- { value : 'pointer'},
- { value : 'copy'},
- { value : 'crosshair'},
- { value : 'grab'},
- { value : 'grabbing'},
- { value : 'help'},
- { value : 'move'},
- { value : 'text'}],
- };
- obj.build('cursor').should.deep.equal([res]);
- });
-
- it('Build overflow', function() {
- var res = {
+ },{
+ property: 'transition-timing-function',
type: 'select',
- property: 'overflow',
- defaults: 'visible',
- list: [{ value : 'visible'},
- { value : 'hidden'},
- { value : 'scroll'},
- { value : 'auto'}],
- };
- obj.build('overflow').should.deep.equal([res]);
- });
-
- });
-
- }
- };
-
-});
\ No newline at end of file
+ defaults: 'ease',
+ list: [{ value : 'linear'},
+ { value : 'ease'},
+ { value : 'ease-in'},
+ { value : 'ease-out'},
+ { value : 'ease-in-out'}],
+ }],
+ };
+ obj.build('transition').should.deep.equal([res]);
+ });
+
+ it('Build perspective', function() {
+ var res = {
+ property: 'perspective',
+ type: 'integer',
+ units: ['px'],
+ defaults : 0,
+ min: 0,
+ };
+ obj.build('perspective').should.deep.equal([res]);
+ });
+
+ it('Build transform', function() {
+ var res = {
+ property: 'transform',
+ type: 'composite',
+ properties:[{
+ property: 'transform-rotate-x',
+ type: 'integer',
+ units: ['deg'],
+ defaults : 0,
+ functionName: 'rotateX',
+ },{
+ property: 'transform-rotate-y',
+ type: 'integer',
+ units: ['deg'],
+ defaults : 0,
+ functionName: 'rotateY',
+ },{
+ property: 'transform-rotate-z',
+ type: 'integer',
+ units: ['deg'],
+ defaults : 0,
+ functionName: 'rotateZ',
+ },{
+ property: 'transform-scale-x',
+ type: 'integer',
+ defaults : 1,
+ functionName: 'scaleX',
+ },{
+ property: 'transform-scale-y',
+ type: 'integer',
+ defaults : 1,
+ functionName: 'scaleY',
+ },{
+ property: 'transform-scale-z',
+ type: 'integer',
+ defaults : 1,
+ functionName: 'scaleZ',
+ }],
+ };
+ obj.build('transform').should.deep.equal([res]);
+ });
+
+ it('Build cursor', function() {
+ var res = {
+ type: 'select',
+ property: 'cursor',
+ defaults: 'auto',
+ list: [{ value : 'auto'},
+ { value : 'pointer'},
+ { value : 'copy'},
+ { value : 'crosshair'},
+ { value : 'grab'},
+ { value : 'grabbing'},
+ { value : 'help'},
+ { value : 'move'},
+ { value : 'text'}],
+ };
+ obj.build('cursor').should.deep.equal([res]);
+ });
+
+ it('Build overflow', function() {
+ var res = {
+ type: 'select',
+ property: 'overflow',
+ defaults: 'visible',
+ list: [{ value : 'visible'},
+ { value : 'hidden'},
+ { value : 'scroll'},
+ { value : 'auto'}],
+ };
+ obj.build('overflow').should.deep.equal([res]);
+ });
+
+ });
+
+ }
+};
diff --git a/test/specs/style_manager/view/LayerView.js b/test/specs/style_manager/view/LayerView.js
index 7b135cc46..e701d16ae 100644
--- a/test/specs/style_manager/view/LayerView.js
+++ b/test/specs/style_manager/view/LayerView.js
@@ -1,81 +1,77 @@
-define(function(require, exports, module){
- 'use strict';
- var LayerView = require('undefined');
- var Layers = require('StyleManager/model/Layers');
+const LayerView = require('style_manager/view/LayerView');
+const Layers = require('style_manager/model/Layers');
- module.exports = {
- run : function(){
+module.exports = {
+ run : function(){
- describe('LayerView', function() {
+ describe('LayerView', function() {
- var component;
- var $fixtures;
- var $fixture;
- var target;
- var model;
- var view;
+ var component;
+ var $fixtures;
+ var $fixture;
+ var target;
+ var model;
+ var view;
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
-
- beforeEach(function () {
- var coll = new Layers();
- model = coll.add({});
- view = new LayerView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('');
+ });
- afterEach(function () {
- view.remove();
- });
+ beforeEach(function () {
+ var coll = new Layers();
+ model = coll.add({});
+ view = new LayerView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- after(function () {
- $fixture.remove();
- delete component;
- delete view;
- delete model;
- });
+ afterEach(function () {
+ view.remove();
+ });
- it('Rendered correctly', function() {
- var layer = view.el;
- $fixture.get(0).querySelector('.layer').should.be.ok;
- layer.querySelector('#label').should.be.ok;
- layer.querySelector('#close-layer').should.be.ok;
- layer.querySelector('#inputs').should.be.ok;
- layer.querySelector('#inputs').innerHTML.should.be.empty;
- layer.querySelector('#preview').should.be.ok;
- });
+ after(function () {
+ $fixture.remove();
+ component = null;
+ view = null;
+ model = null;
+ });
- it('getIndex returns default value', function() {
- view.getIndex().should.equal(0);
- });
+ it('Rendered correctly', function() {
+ var layer = view.el;
+ $fixture.get(0).querySelector('.layer').should.be.ok;
+ layer.querySelector('#label').should.be.ok;
+ layer.querySelector('#close-layer').should.be.ok;
+ layer.querySelector('#inputs').should.be.ok;
+ layer.querySelector('#inputs').innerHTML.should.be.empty;
+ layer.querySelector('#preview').should.be.ok;
+ });
- it('No preview', function() {
- var style = view.el.querySelector('#preview').style;
- style.cssText.should.be.empty;
- });
+ it('getIndex returns default value', function() {
+ view.getIndex().should.equal(0);
+ });
- it('Changes on value trigger onPreview', function() {
- var called = 0;
- view.onPreview = function(){called = 1};
- view.model.set('preview', true);
- view.model.set('value', 'test');
- called.should.equal(1);
- });
+ it('No preview', function() {
+ var style = view.el.querySelector('#preview').style;
+ style.cssText.should.be.empty;
+ });
- it('Update props', function() {
- view.model.set('props', $(''));
- view.el.querySelector('#inputs').innerHTML.should.not.be.empty;
- (view.model.get('props') === null).should.equal(true);
- });
+ it('Changes on value trigger onPreview', function() {
+ var called = 0;
+ view.onPreview = function(){called = 1};
+ view.model.set('preview', true);
+ view.model.set('value', 'test');
+ called.should.equal(1);
+ });
+ it('Update props', function() {
+ view.model.set('props', $('
'));
+ view.el.querySelector('#inputs').innerHTML.should.not.be.empty;
+ (view.model.get('props') === null).should.equal(true);
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/PropertyColorView.js b/test/specs/style_manager/view/PropertyColorView.js
index f674503cd..5dd52d4c8 100644
--- a/test/specs/style_manager/view/PropertyColorView.js
+++ b/test/specs/style_manager/view/PropertyColorView.js
@@ -1,166 +1,162 @@
-define(function(require, exports, module){
- 'use strict';
- var PropertyColorView = require('undefined');
- var Property = require('StyleManager/model/Property');
- var Component = require('DomComponents/model/Component');
-
- module.exports = {
- run : function(){
-
- describe('PropertyColorView', function() {
-
- var component;
- var $fixtures;
- var $fixture;
- var target;
- var model;
- var view;
- var propName = 'testprop';
- var propValue = '#fff';
- var defValue = 'test2value';
-
- before(function () {
- $.fn.spectrum = function(){};
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
+const PropertyColorView = require('style_manager/view/PropertyColorView');
+const Property = require('style_manager/model/Property');
+const Component = require('dom_components/model/Component');
+
+module.exports = {
+ run : function(){
+
+ describe('PropertyColorView', function() {
+
+ var component;
+ var $fixtures;
+ var $fixture;
+ var target;
+ var model;
+ var view;
+ var propName = 'testprop';
+ var propValue = '#fff';
+ var defValue = 'test2value';
+
+ before(function () {
+ $.fn.spectrum = function(){};
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
- beforeEach(function () {
- target = new Component();
- component = new Component();
- model = new Property({
- type: 'color',
- property: propName
- });
- view = new PropertyColorView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+ beforeEach(function () {
+ target = new Component();
+ component = new Component();
+ model = new Property({
+ type: 'color',
+ property: propName
+ });
+ view = new PropertyColorView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- afterEach(function () {
- //view.remove(); // strange errors ???
- });
+ afterEach(function () {
+ //view.remove(); // strange errors ???
+ });
- after(function () {
- $fixture.remove();
- delete component;
- delete view;
- delete model;
- });
+ after(function () {
+ $fixture.remove();
+ component = null;
+ view = null;
+ model = null;
+ });
- it('Rendered correctly', function() {
- var prop = view.el;
- $fixture.get(0).querySelector('.property').should.be.ok;
- prop.querySelector('.label').should.be.ok;
- prop.querySelector('.field').should.be.ok;
- });
+ it('Rendered correctly', function() {
+ var prop = view.el;
+ $fixture.get(0).querySelector('.property').should.be.ok;
+ prop.querySelector('.label').should.be.ok;
+ prop.querySelector('.field').should.be.ok;
+ });
- it('Inputs rendered', function() {
- var prop = view.el;
- prop.querySelector('input[type=text]').should.be.ok;
- prop.querySelector('.field-color-picker').should.be.ok;
- });
+ it('Inputs rendered', function() {
+ var prop = view.el;
+ prop.querySelector('input[type=text]').should.be.ok;
+ prop.querySelector('.field-color-picker').should.be.ok;
+ });
- it('Inputs should exist', function() {
- view.$input.should.be.ok;
- view.$color.should.be.ok;
- });
+ it('Inputs should exist', function() {
+ view.$input.should.be.ok;
+ view.$color.should.be.ok;
+ });
- it('Input value is empty', function() {
- view.model.get('value').should.be.empty;
- view.$input.val().should.be.empty;
- });
+ it('Input value is empty', function() {
+ view.model.get('value').should.be.empty;
+ view.$input.val().should.be.empty;
+ });
- it('Update model on setValue', function() {
- view.setValue(propValue);
- view.model.get('value').should.equal(propValue);
- view.$input.val().should.equal(propValue);
- });
+ it('Update model on setValue', function() {
+ view.setValue(propValue);
+ view.model.get('value').should.equal(propValue);
+ view.$input.val().should.equal(propValue);
+ });
- it('Update model on input change', function() {
- view.$input.val(propValue).trigger('change');
- view.model.get('value').should.equal(propValue);
- });
+ it('Update model on input change', function() {
+ view.$input.val(propValue).trigger('change');
+ view.model.get('value').should.equal(propValue);
+ });
- it('Update input on value change', function() {
- view.model.set('value', propValue);
- view.getInputValue().should.equal(propValue);
- });
+ it('Update input on value change', function() {
+ view.model.set('value', propValue);
+ view.getInputValue().should.equal(propValue);
+ });
- it('Update target on value change', function() {
- view.selectedComponent = component;
- view.model.set('value', propValue);
- var compStyle = view.selectedComponent.get('style');
- var assertStyle = {};
- assertStyle[propName] = propValue;
- compStyle.should.deep.equal(assertStyle);
- });
+ it('Update target on value change', function() {
+ view.selectedComponent = component;
+ view.model.set('value', propValue);
+ var compStyle = view.selectedComponent.get('style');
+ var assertStyle = {};
+ assertStyle[propName] = propValue;
+ compStyle.should.deep.equal(assertStyle);
+ });
- describe('With target setted', function() {
-
- beforeEach(function () {
- target.model = component;
- view = new PropertyColorView({
- model: model,
- propTarget: target
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Update value and input on target swap', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal(propValue);
- view.getInputValue().should.equal(propValue);
- });
-
- it('Update value after multiple swaps', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- style[propName] = '#123123';
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal('#123123');
- view.$input.val().should.equal('#123123');
- });
-
- })
-
- describe('Init property', function() {
-
- beforeEach(function () {
- component = new Component();
- model = new Property({
- type: 'color',
- property: propName,
- defaults: propValue,
- });
- view = new PropertyColorView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Value as default', function() {
- view.model.get('value').should.equal(propValue);
- });
-
- it('Input value is as default', function() {
- view.$input.val().should.equal(propValue);
- });
+ describe('With target setted', function() {
+ beforeEach(function () {
+ target.model = component;
+ view = new PropertyColorView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Update value and input on target swap', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal(propValue);
+ view.getInputValue().should.equal(propValue);
+ });
+
+ it('Update value after multiple swaps', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ style[propName] = '#123123';
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal('#123123');
+ view.$input.val().should.equal('#123123');
+ });
+
+ })
+
+ describe('Init property', function() {
+
+ beforeEach(function () {
+ component = new Component();
+ model = new Property({
+ type: 'color',
+ property: propName,
+ defaults: propValue,
});
+ view = new PropertyColorView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Value as default', function() {
+ view.model.get('value').should.equal(propValue);
+ });
+
+ it('Input value is as default', function() {
+ view.$input.val().should.equal(propValue);
+ });
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/PropertyCompositeView.js b/test/specs/style_manager/view/PropertyCompositeView.js
index bd6bd778e..106de67de 100644
--- a/test/specs/style_manager/view/PropertyCompositeView.js
+++ b/test/specs/style_manager/view/PropertyCompositeView.js
@@ -1,242 +1,238 @@
-define(function(require, exports, module){
- 'use strict';
- var PropertyCompositeView = require('undefined');
- var Property = require('StyleManager/model/Property');
- var Component = require('DomComponents/model/Component');
-
- module.exports = {
- run : function(){
-
- describe('PropertyCompositeView', function() {
-
- var component;
- var $fixtures;
- var $fixture;
- var target;
- var model;
- var view;
- var propName = 'testprop';
- var propValue = 'test1value';
- var defValue = 'test2value';
- var properties = [
- {property: 'subprop1'},
- {
- type: 'integer',
- property: 'subprop2',
- defaults: 0,
- units: ['%', 'px']
- },
- {
- type: 'select',
- property: 'subprop3',
- defaults: 'val2',
- list: [
- {value:'val1'},
- {value:'val2'},
- {value:'val3'},
- ]
- },
- ];
-
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
-
- beforeEach(function () {
- target = new Component();
- component = new Component();
- target.model = component;
- model = new Property({
- type: 'composite',
- property: propName,
- properties: properties
- });
- view = new PropertyCompositeView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+const PropertyCompositeView = require('style_manager/view/PropertyCompositeView');
+const Property = require('style_manager/model/Property');
+const Component = require('dom_components/model/Component');
+
+module.exports = {
+ run : function(){
+
+ describe('PropertyCompositeView', function() {
+
+ var component;
+ var $fixtures;
+ var $fixture;
+ var target;
+ var model;
+ var view;
+ var propName = 'testprop';
+ var propValue = 'test1value';
+ var defValue = 'test2value';
+ var properties = [
+ {property: 'subprop1'},
+ {
+ type: 'integer',
+ property: 'subprop2',
+ defaults: 0,
+ units: ['%', 'px']
+ },
+ {
+ type: 'select',
+ property: 'subprop3',
+ defaults: 'val2',
+ list: [
+ {value:'val1'},
+ {value:'val2'},
+ {value:'val3'},
+ ]
+ },
+ ];
+
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
- afterEach(function () {
- //view.remove(); // strange errors ???
- });
+ beforeEach(function () {
+ target = new Component();
+ component = new Component();
+ target.model = component;
+ model = new Property({
+ type: 'composite',
+ property: propName,
+ properties: properties
+ });
+ view = new PropertyCompositeView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- after(function () {
- $fixture.remove();
- delete component;
- delete view;
- delete model;
- });
+ afterEach(function () {
+ //view.remove(); // strange errors ???
+ });
- it('Rendered correctly', function() {
- var prop = view.el;
- $fixture.get(0).querySelector('.property').should.be.ok;
- prop.querySelector('.label').should.be.ok;
- prop.querySelector('.field').should.be.ok;
- });
+ after(function () {
+ $fixture.remove();
+ component = null;
+ view = null;
+ model = null;
+ });
- it('Properties rendered', function() {
- var prop = view.el;
- prop.querySelector('.properties').should.be.ok;
- });
+ it('Rendered correctly', function() {
+ var prop = view.el;
+ $fixture.get(0).querySelector('.property').should.be.ok;
+ prop.querySelector('.label').should.be.ok;
+ prop.querySelector('.field').should.be.ok;
+ });
- it('Properties rendered correctly', function() {
- var children = view.el.querySelector('.properties').children;
- children.length.should.equal(properties.length + 1);
- children[0].id.should.equal(properties[0].property);
- children[1].id.should.equal(properties[1].property);
- children[2].id.should.equal(properties[2].property);
- });
+ it('Properties rendered', function() {
+ var prop = view.el;
+ prop.querySelector('.properties').should.be.ok;
+ });
- it('Props should exist', function() {
- view.$props.should.be.ok;
- });
+ it('Properties rendered correctly', function() {
+ var children = view.el.querySelector('.properties').children;
+ children.length.should.equal(properties.length + 1);
+ children[0].id.should.equal(properties[0].property);
+ children[1].id.should.equal(properties[1].property);
+ children[2].id.should.equal(properties[2].property);
+ });
- it('Input value is empty', function() {
- view.model.get('value').should.be.empty;
- });
+ it('Props should exist', function() {
+ view.$props.should.be.ok;
+ });
- it('Update input on value change', function() {
- view.model.set('value', propValue);
- view.$input.val().should.equal(propValue);
- });
+ it('Input value is empty', function() {
+ view.model.get('value').should.be.empty;
+ });
- describe('With target setted', function() {
-
- var prop2Val;
- var prop3Val;
- var prop2Unit;
- var finalResult;
- var $prop1;
- var $prop2;
- var $prop3;
-
- beforeEach(function () {
- model = new Property({
- type: 'composite',
- property: propName,
- properties: properties
- });
- view = new PropertyCompositeView({
- model: model,
- propTarget: target
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- prop3Val = properties[2].list[2].value;
- prop2Val = properties[1].defaults;
- prop2Unit = properties[1].units[0];
- finalResult = propValue + ' ' + prop2Val + prop2Unit +' ' + prop3Val;
- $prop1 = view.$props.find('#' + properties[0].property + ' input');
- $prop2 = view.$props.find('#' + properties[1].property + ' input');
- $prop3 = view.$props.find('#' + properties[2].property + ' select');
- });
-
- it('Update model on input change', function() {
- $prop1.val(propValue).trigger('change');
- $prop3.val(prop3Val).trigger('change');
- view.model.get('value').should.equal(finalResult);
- });
-
- it('Update value on models change', function() {
- view.model.get('properties').at(0).set('value', propValue);
- view.model.get('properties').at(2).set('value', prop3Val);
- view.model.get('value').should.equal(finalResult);
- });
-
- it('Update target on value change', function() {
- $prop1.val(propValue).trigger('change');
- var compStyle = view.getTarget().get('style');
- var assertStyle = {};
- assertStyle[propName] = propValue + ' 0% val2';
- compStyle.should.deep.equal(assertStyle);
- });
-
- it('Update target on detached value change', function() {
- model = new Property({
- type: 'composite',
- property: propName,
- properties: properties,
- detached: true,
- });
- view = new PropertyCompositeView({
- model: model,
- propTarget: target
- });
- $fixture.html(view.render().el);
- $prop1 = view.$props.find('#' + properties[0].property + ' input');
- $prop1.val(propValue).trigger('change');
- var compStyle = view.getTarget().get('style');
- var assertStyle = {};
- assertStyle[properties[0].property] = $prop1.val();
- compStyle.should.deep.equal(assertStyle);
- });
-
- it('Update value and input on target swap', function() {
- var style = {};
- style[propName] = finalResult;
- component.set('style', style);
- view.propTarget.trigger('update');
- $prop1.val().should.equal(propValue);
- $prop3.val().should.equal(prop3Val);
- });
-
- it('Update value after multiple swaps', function() {
- var style = {};
- style[propName] = finalResult;
- component.set('style', style);
- view.propTarget.trigger('update');
- style[propName] = propValue + '2 ' + prop2Val + '2' + prop2Unit + ' ' + 'val1';
- component.set('style', style);
- view.propTarget.trigger('update');
- $prop1.val().should.equal(propValue + '2');
- $prop2.val().should.equal('2');
- $prop3.val().should.equal('val1');
- });
-
- it('The value is correctly extracted from the composite string', function() {
- var style = {};
- style[propName] = 'value1 value2 value3 value4';
- component.set('style', style);
- view.valueOnIndex(2).should.equal('value3');
- view.valueOnIndex(0).should.equal('value1');
- (view.valueOnIndex(4) === null).should.equal(true);
- });
-
- it('Build value from properties', function() {
- view.model.get('properties').at(0).set('value', propValue);
- view.model.get('properties').at(2).set('value', prop3Val);
- view.build().should.equal(finalResult);
- });
-
- })
-
- describe('Init property', function() {
-
- beforeEach(function () {
- model = new Property({
- type: 'composite',
- property: propName,
- properties: properties,
- defaults: defValue,
- });
- view = new PropertyCompositeView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Value as default', function() {
- view.model.get('value').should.equal(defValue);
- });
+ it('Update input on value change', function() {
+ view.model.set('value', propValue);
+ view.$input.val().should.equal(propValue);
+ });
+ describe('With target setted', function() {
+
+ var prop2Val;
+ var prop3Val;
+ var prop2Unit;
+ var finalResult;
+ var $prop1;
+ var $prop2;
+ var $prop3;
+
+ beforeEach(function () {
+ model = new Property({
+ type: 'composite',
+ property: propName,
+ properties: properties
});
+ view = new PropertyCompositeView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ prop3Val = properties[2].list[2].value;
+ prop2Val = properties[1].defaults;
+ prop2Unit = properties[1].units[0];
+ finalResult = propValue + ' ' + prop2Val + prop2Unit +' ' + prop3Val;
+ $prop1 = view.$props.find('#' + properties[0].property + ' input');
+ $prop2 = view.$props.find('#' + properties[1].property + ' input');
+ $prop3 = view.$props.find('#' + properties[2].property + ' select');
+ });
+
+ it('Update model on input change', function() {
+ $prop1.val(propValue).trigger('change');
+ $prop3.val(prop3Val).trigger('change');
+ view.model.get('value').should.equal(finalResult);
+ });
+
+ it('Update value on models change', function() {
+ view.model.get('properties').at(0).set('value', propValue);
+ view.model.get('properties').at(2).set('value', prop3Val);
+ view.model.get('value').should.equal(finalResult);
+ });
+
+ it('Update target on value change', function() {
+ $prop1.val(propValue).trigger('change');
+ var compStyle = view.getTarget().get('style');
+ var assertStyle = {};
+ assertStyle[propName] = propValue + ' 0% val2';
+ compStyle.should.deep.equal(assertStyle);
+ });
+
+ it('Update target on detached value change', function() {
+ model = new Property({
+ type: 'composite',
+ property: propName,
+ properties: properties,
+ detached: true,
+ });
+ view = new PropertyCompositeView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.html(view.render().el);
+ $prop1 = view.$props.find('#' + properties[0].property + ' input');
+ $prop1.val(propValue).trigger('change');
+ var compStyle = view.getTarget().get('style');
+ var assertStyle = {};
+ assertStyle[properties[0].property] = $prop1.val();
+ compStyle.should.deep.equal(assertStyle);
+ });
+
+ it('Update value and input on target swap', function() {
+ var style = {};
+ style[propName] = finalResult;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ $prop1.val().should.equal(propValue);
+ $prop3.val().should.equal(prop3Val);
+ });
+
+ it('Update value after multiple swaps', function() {
+ var style = {};
+ style[propName] = finalResult;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ style[propName] = propValue + '2 ' + prop2Val + '2' + prop2Unit + ' ' + 'val1';
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ $prop1.val().should.equal(propValue + '2');
+ $prop2.val().should.equal('2');
+ $prop3.val().should.equal('val1');
+ });
+
+ it('The value is correctly extracted from the composite string', function() {
+ var style = {};
+ style[propName] = 'value1 value2 value3 value4';
+ component.set('style', style);
+ view.valueOnIndex(2).should.equal('value3');
+ view.valueOnIndex(0).should.equal('value1');
+ (view.valueOnIndex(4) === null).should.equal(true);
+ });
+
+ it('Build value from properties', function() {
+ view.model.get('properties').at(0).set('value', propValue);
+ view.model.get('properties').at(2).set('value', prop3Val);
+ view.build().should.equal(finalResult);
+ });
+
+ })
+
+ describe('Init property', function() {
+
+ beforeEach(function () {
+ model = new Property({
+ type: 'composite',
+ property: propName,
+ properties: properties,
+ defaults: defValue,
+ });
+ view = new PropertyCompositeView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Value as default', function() {
+ view.model.get('value').should.equal(defValue);
+ });
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/PropertyIntegerView.js b/test/specs/style_manager/view/PropertyIntegerView.js
index 93e077959..d04de7c08 100644
--- a/test/specs/style_manager/view/PropertyIntegerView.js
+++ b/test/specs/style_manager/view/PropertyIntegerView.js
@@ -1,211 +1,207 @@
-define(function(require, exports, module){
- 'use strict';
- var PropertyIntegerView = require('undefined');
- var Property = require('StyleManager/model/Property');
- var Component = require('DomComponents/model/Component');
-
- module.exports = {
- run : function(){
-
- describe('PropertyIntegerView', function() {
-
- var component;
- var $fixtures;
- var $fixture;
- var target;
- var model;
- var view;
- var propName = 'testprop';
- var intValue = '55';
- var unitValue = 'px';
- var propValue = intValue + unitValue;
- var defValue = 'test2value';
- var units = ['px', '%', 'em'];
- var minValue = -15;
- var maxValue = 75;
- var unitsElSel = '.field-units select';
-
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
-
- beforeEach(function () {
- target = new Component();
- component = new Component();
- model = new Property({
- type: 'integer',
- units: units,
- property: propName
- });
- view = new PropertyIntegerView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+const PropertyIntegerView = require('style_manager/view/PropertyIntegerView');
+const Property = require('style_manager/model/Property');
+const Component = require('dom_components/model/Component');
+
+module.exports = {
+ run : function(){
+
+ describe('PropertyIntegerView', function() {
+
+ var component;
+ var $fixtures;
+ var $fixture;
+ var target;
+ var model;
+ var view;
+ var propName = 'testprop';
+ var intValue = '55';
+ var unitValue = 'px';
+ var propValue = intValue + unitValue;
+ var defValue = 'test2value';
+ var units = ['px', '%', 'em'];
+ var minValue = -15;
+ var maxValue = 75;
+ var unitsElSel = '.field-units select';
+
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
- afterEach(function () {
- //view.remove(); // strange errors ???
- });
+ beforeEach(function () {
+ target = new Component();
+ component = new Component();
+ model = new Property({
+ type: 'integer',
+ units: units,
+ property: propName
+ });
+ view = new PropertyIntegerView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- after(function () {
- $fixture.remove();
- delete component;
- delete view;
- delete model;
- });
+ afterEach(function () {
+ //view.remove(); // strange errors ???
+ });
- it('Rendered correctly', function() {
- var prop = view.el;
- $fixture.get(0).querySelector('.property').should.be.ok;
- prop.querySelector('.label').should.be.ok;
- prop.querySelector('.field').should.be.ok;
- });
+ after(function () {
+ $fixture.remove();
+ component = null;
+ view = null;
+ model = null;
+ });
- it('Inputs rendered', function() {
- var prop = view.el;
- prop.querySelector('input[type=text]').should.be.ok;
- prop.querySelector(unitsElSel).should.be.ok;
- });
+ it('Rendered correctly', function() {
+ var prop = view.el;
+ $fixture.get(0).querySelector('.property').should.be.ok;
+ prop.querySelector('.label').should.be.ok;
+ prop.querySelector('.field').should.be.ok;
+ });
- it('Units rendered', function() {
- var select = view.el.querySelector(unitsElSel);
- select.children.length.should.equal(units.length);
- });
+ it('Inputs rendered', function() {
+ var prop = view.el;
+ prop.querySelector('input[type=text]').should.be.ok;
+ prop.querySelector(unitsElSel).should.be.ok;
+ });
- it('Units rendered correctly', function() {
- var children = view.el.querySelector(unitsElSel).children;
- children[0].textContent.should.equal(units[0]);
- children[1].textContent.should.equal(units[1]);
- children[2].textContent.should.equal(units[2]);
- });
+ it('Units rendered', function() {
+ var select = view.el.querySelector(unitsElSel);
+ select.children.length.should.equal(units.length);
+ });
- it('Inputs should exist', function() {
- view.$input.should.be.ok;
- view.$unit.should.be.ok;
- });
+ it('Units rendered correctly', function() {
+ var children = view.el.querySelector(unitsElSel).children;
+ children[0].textContent.should.equal(units[0]);
+ children[1].textContent.should.equal(units[1]);
+ children[2].textContent.should.equal(units[2]);
+ });
- it('Input value is empty', function() {
- view.model.get('value').should.be.empty;
- view.model.get('unit').should.equal('px');
- });
+ it('Inputs should exist', function() {
+ view.$input.should.be.ok;
+ view.$unit.should.be.ok;
+ });
- it('Update model on setValue', function() {
- view.setValue(intValue + unitValue);
- view.model.get('value').should.equal(parseFloat(intValue));
- view.model.get('unit').should.equal(unitValue);
- view.$input.val().should.equal(intValue);
- view.$unit.val().should.equal(unitValue);
- });
+ it('Input value is empty', function() {
+ view.model.get('value').should.be.empty;
+ view.model.get('unit').should.equal('px');
+ });
- it('Update model on input change', function() {
- view.$input.val(123).trigger('change');
- view.model.get('value').should.equal(123);
- });
+ it('Update model on setValue', function() {
+ view.setValue(intValue + unitValue);
+ view.model.get('value').should.equal(parseFloat(intValue));
+ view.model.get('unit').should.equal(unitValue);
+ view.$input.val().should.equal(intValue);
+ view.$unit.val().should.equal(unitValue);
+ });
- it('Update model on unit change', function() {
- view.$unit.val(units[1]).trigger('change');
- view.model.get('unit').should.equal(units[1]);
- });
+ it('Update model on input change', function() {
+ view.$input.val(123).trigger('change');
+ view.model.get('value').should.equal(123);
+ });
- it('Update input on value change', function() {
- view.model.set('value', intValue);
- view.getInputValue().should.equal(intValue);
- });
+ it('Update model on unit change', function() {
+ view.$unit.val(units[1]).trigger('change');
+ view.model.get('unit').should.equal(units[1]);
+ });
- it('Update target on value change', function() {
- view.selectedComponent = component;
- view.model.set('value', intValue);
- var compStyle = view.selectedComponent.get('style');
- var assertStyle = {};
- assertStyle[propName] = propValue;
- compStyle.should.deep.equal(assertStyle);
- });
+ it('Update input on value change', function() {
+ view.model.set('value', intValue);
+ view.getInputValue().should.equal(intValue);
+ });
- describe('With target setted', function() {
-
- beforeEach(function () {
- target.model = component;
- view = new PropertyIntegerView({
- model: model,
- propTarget: target
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Update value and input on target swap', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal(parseFloat(intValue));
- view.getInputValue().should.equal(intValue);
- });
-
- it('Update value after multiple swaps', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- style[propName] = '20em';
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal(20);
- view.model.get('unit').should.equal('em');
- view.$input.val().should.equal('20');
- view.$unit.val().should.equal('em');
- });
-
- })
-
- describe('Init property', function() {
-
- beforeEach(function () {
- component = new Component();
- model = new Property({
- type: 'integer',
- units: units,
- property: propName,
- defaults: intValue,
- min: minValue,
- max: maxValue,
- unit: units[1],
- });
- view = new PropertyIntegerView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Value as default', function() {
- view.model.get('value').should.equal(parseInt(intValue));
- view.model.get('unit').should.equal(units[1]);
- });
-
- it('Input value is as default', function() {
- view.$input.val().should.equal(intValue);
- view.$unit.val().should.equal(units[1]);
- });
-
- it('Input follows min', function() {
- view.$input.val(minValue - 50).trigger('change');
- view.model.get('value').should.equal(minValue);
- view.$input.val().should.equal(minValue + "");
- });
-
- it('Input follows max', function() {
- view.$input.val(maxValue + 50).trigger('change');
- view.model.get('value').should.equal(maxValue);
- view.$input.val().should.equal(maxValue + "");
- });
+ it('Update target on value change', function() {
+ view.selectedComponent = component;
+ view.model.set('value', intValue);
+ var compStyle = view.selectedComponent.get('style');
+ var assertStyle = {};
+ assertStyle[propName] = propValue;
+ compStyle.should.deep.equal(assertStyle);
+ });
- });
+ describe('With target setted', function() {
+
+ beforeEach(function () {
+ target.model = component;
+ view = new PropertyIntegerView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Update value and input on target swap', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal(parseFloat(intValue));
+ view.getInputValue().should.equal(intValue);
+ });
+
+ it('Update value after multiple swaps', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ style[propName] = '20em';
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal(20);
+ view.model.get('unit').should.equal('em');
+ view.$input.val().should.equal('20');
+ view.$unit.val().should.equal('em');
+ });
+
+ })
+
+ describe('Init property', function() {
+
+ beforeEach(function () {
+ component = new Component();
+ model = new Property({
+ type: 'integer',
+ units: units,
+ property: propName,
+ defaults: intValue,
+ min: minValue,
+ max: maxValue,
+ unit: units[1],
+ });
+ view = new PropertyIntegerView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Value as default', function() {
+ view.model.get('value').should.equal(parseInt(intValue));
+ view.model.get('unit').should.equal(units[1]);
+ });
+
+ it('Input value is as default', function() {
+ view.$input.val().should.equal(intValue);
+ view.$unit.val().should.equal(units[1]);
+ });
+
+ it('Input follows min', function() {
+ view.$input.val(minValue - 50).trigger('change');
+ view.model.get('value').should.equal(minValue);
+ view.$input.val().should.equal(minValue + "");
+ });
+
+ it('Input follows max', function() {
+ view.$input.val(maxValue + 50).trigger('change');
+ view.model.get('value').should.equal(maxValue);
+ view.$input.val().should.equal(maxValue + "");
+ });
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/PropertyRadioView.js b/test/specs/style_manager/view/PropertyRadioView.js
index 0370b75fa..0bbd2c375 100644
--- a/test/specs/style_manager/view/PropertyRadioView.js
+++ b/test/specs/style_manager/view/PropertyRadioView.js
@@ -1,177 +1,173 @@
-define(function(require, exports, module){
- 'use strict';
- var PropertyRadioView = require('undefined');
- var Property = require('StyleManager/model/Property');
- var Component = require('DomComponents/model/Component');
-
- module.exports = {
- run : function(){
-
- describe('PropertyRadioView', function() {
-
- var component;
- var $fixtures;
- var $fixture;
- var target;
- var model;
- var view;
- var propName = 'testprop';
- var propValue = 'test1value';
- var defValue = 'test2value';
- var options = [
- { value: 'test1value', 'title': 'testtitle'},
- { name: 'test2', value: 'test2value'}
- ];
-
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
+const PropertyRadioView = require('style_manager/view/PropertyRadioView');
+const Property = require('style_manager/model/Property');
+const Component = require('dom_components/model/Component');
+
+module.exports = {
+ run : function(){
+
+ describe('PropertyRadioView', function() {
+
+ var component;
+ var $fixtures;
+ var $fixture;
+ var target;
+ var model;
+ var view;
+ var propName = 'testprop';
+ var propValue = 'test1value';
+ var defValue = 'test2value';
+ var options = [
+ { value: 'test1value', 'title': 'testtitle'},
+ { name: 'test2', value: 'test2value'}
+ ];
+
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
- beforeEach(function () {
- target = new Component();
- component = new Component();
- model = new Property({
- type: 'radio',
- list: options,
- property: propName
- });
- view = new PropertyRadioView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+ beforeEach(function () {
+ target = new Component();
+ component = new Component();
+ model = new Property({
+ type: 'radio',
+ list: options,
+ property: propName
+ });
+ view = new PropertyRadioView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- afterEach(function () {
- //view.remove(); // strange errors ???
- });
+ afterEach(function () {
+ //view.remove(); // strange errors ???
+ });
- after(function () {
- $fixture.remove();
- delete component;
- });
+ after(function () {
+ $fixture.remove();
+ component = null;
+ });
- it('Rendered correctly', function() {
- var prop = view.el;
- $fixture.get(0).querySelector('.property').should.be.ok;
- prop.querySelector('.label').should.be.ok;
- prop.querySelector('.field').should.be.ok;
- });
+ it('Rendered correctly', function() {
+ var prop = view.el;
+ $fixture.get(0).querySelector('.property').should.be.ok;
+ prop.querySelector('.label').should.be.ok;
+ prop.querySelector('.field').should.be.ok;
+ });
- it('Radio rendered', function() {
- var prop = view.el;
- prop.querySelector('input[type=radio]').should.be.ok;
- });
+ it('Radio rendered', function() {
+ var prop = view.el;
+ prop.querySelector('input[type=radio]').should.be.ok;
+ });
- it('Options rendered', function() {
- var input = view.el.querySelector('#input-holder');
- input.children.length.should.equal(options.length);
- });
+ it('Options rendered', function() {
+ var input = view.el.querySelector('#input-holder');
+ input.children.length.should.equal(options.length);
+ });
- it('Options rendered correctly', function() {
- var children = view.el.querySelector('#input-holder').children;
- children[0].querySelector('label').textContent.should.equal('test1value');
- children[1].querySelector('label').textContent.should.equal('test2');
- children[0].querySelector('input').value.should.equal(options[0].value);
- children[1].querySelector('input').value.should.equal(options[1].value);
- children[0].querySelector('label').getAttribute('title').should.equal(options[0].title);
- (children[1].querySelector('label').getAttribute('title') == null)
- .should.equal(true);
- });
+ it('Options rendered correctly', function() {
+ var children = view.el.querySelector('#input-holder').children;
+ children[0].querySelector('label').textContent.should.equal('test1value');
+ children[1].querySelector('label').textContent.should.equal('test2');
+ children[0].querySelector('input').value.should.equal(options[0].value);
+ children[1].querySelector('input').value.should.equal(options[1].value);
+ children[0].querySelector('label').getAttribute('title').should.equal(options[0].title);
+ (children[1].querySelector('label').getAttribute('title') == null)
+ .should.equal(true);
+ });
- it('Input should exist', function() {
- view.$input.should.be.ok;
- });
+ it('Input should exist', function() {
+ view.$input.should.be.ok;
+ });
- it('Input value is empty', function() {
- view.model.get('value').should.be.empty;
- });
+ it('Input value is empty', function() {
+ view.model.get('value').should.be.empty;
+ });
- it('Update model on input change', function() {
- view.setValue(propValue);
- view.model.get('value').should.equal(propValue);
- view.getInputValue().should.equal(propValue);
- });
+ it('Update model on input change', function() {
+ view.setValue(propValue);
+ view.model.get('value').should.equal(propValue);
+ view.getInputValue().should.equal(propValue);
+ });
- it('Update input on value change', function() {
- view.model.set('value', propValue);
- view.getInputValue().should.equal(propValue);
- });
+ it('Update input on value change', function() {
+ view.model.set('value', propValue);
+ view.getInputValue().should.equal(propValue);
+ });
- it('Update target on value change', function() {
- view.selectedComponent = component;
- view.model.set('value', propValue);
- var compStyle = view.selectedComponent.get('style');
- var assertStyle = {};
- assertStyle[propName] = propValue;
- compStyle.should.deep.equal(assertStyle);
- });
+ it('Update target on value change', function() {
+ view.selectedComponent = component;
+ view.model.set('value', propValue);
+ var compStyle = view.selectedComponent.get('style');
+ var assertStyle = {};
+ assertStyle[propName] = propValue;
+ compStyle.should.deep.equal(assertStyle);
+ });
- describe('With target setted', function() {
-
- beforeEach(function () {
- target.model = component;
- view = new PropertyRadioView({
- model: model,
- propTarget: target
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Update value and input on target swap', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal(propValue);
- view.getInputValue().should.equal(propValue);
- });
-
- it('Update value after multiple swaps', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- style[propName] = 'test2value';
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal('test2value');
- view.getInputValue().should.equal('test2value');
- });
-
- })
-
- describe('Init property', function() {
-
- beforeEach(function () {
- component = new Component();
- model = new Property({
- type: 'select',
- list: options,
- defaults: defValue,
- property: propName
- });
- view = new PropertyRadioView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Value as default', function() {
- view.model.get('value').should.equal(defValue);
- });
-
- it('Input value is as default', function() {
- view.getInputValue().should.equal(defValue);
- });
+ describe('With target setted', function() {
+ beforeEach(function () {
+ target.model = component;
+ view = new PropertyRadioView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Update value and input on target swap', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal(propValue);
+ view.getInputValue().should.equal(propValue);
+ });
+
+ it('Update value after multiple swaps', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ style[propName] = 'test2value';
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal('test2value');
+ view.getInputValue().should.equal('test2value');
+ });
+
+ })
+
+ describe('Init property', function() {
+
+ beforeEach(function () {
+ component = new Component();
+ model = new Property({
+ type: 'select',
+ list: options,
+ defaults: defValue,
+ property: propName
});
+ view = new PropertyRadioView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Value as default', function() {
+ view.model.get('value').should.equal(defValue);
+ });
+
+ it('Input value is as default', function() {
+ view.getInputValue().should.equal(defValue);
+ });
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/PropertySelectView.js b/test/specs/style_manager/view/PropertySelectView.js
index aa91d119d..81fb328e1 100644
--- a/test/specs/style_manager/view/PropertySelectView.js
+++ b/test/specs/style_manager/view/PropertySelectView.js
@@ -1,196 +1,192 @@
-define(function(require, exports, module){
- 'use strict';
- var PropertySelectView = require('undefined');
- var Property = require('StyleManager/model/Property');
- var Component = require('DomComponents/model/Component');
-
- module.exports = {
- run : function(){
-
- describe('PropertySelectView', function() {
-
- var component;
- var $fixtures;
- var $fixture;
- var target;
- var model;
- var view;
- var propName = 'testprop';
- var propValue = 'test1value';
- var defValue = 'test2value';
- var options = [
- {value: 'test1value', style: 'test:style'},
- {name: 'test2', value: 'test2value'}
- ];
-
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
+const PropertySelectView = require('style_manager/view/PropertySelectView');
+const Property = require('style_manager/model/Property');
+const Component = require('dom_components/model/Component');
+
+module.exports = {
+ run : function(){
+
+ describe('PropertySelectView', function() {
+
+ var component;
+ var $fixtures;
+ var $fixture;
+ var target;
+ var model;
+ var view;
+ var propName = 'testprop';
+ var propValue = 'test1value';
+ var defValue = 'test2value';
+ var options = [
+ {value: 'test1value', style: 'test:style'},
+ {name: 'test2', value: 'test2value'}
+ ];
+
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
- beforeEach(function () {
- target = new Component();
- component = new Component();
- model = new Property({
- type: 'select',
- list: options,
- property: propName
- });
- view = new PropertySelectView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+ beforeEach(function () {
+ target = new Component();
+ component = new Component();
+ model = new Property({
+ type: 'select',
+ list: options,
+ property: propName
+ });
+ view = new PropertySelectView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- afterEach(function () {
- //view.remove(); // strange errors ???
- });
+ afterEach(function () {
+ //view.remove(); // strange errors ???
+ });
- after(function () {
- $fixture.remove();
- delete component;
- });
+ after(function () {
+ $fixture.remove();
+ component = null;
+ });
- it('Rendered correctly', function() {
- var prop = view.el;
- $fixture.get(0).querySelector('.property').should.be.ok;
- prop.querySelector('.label').should.be.ok;
- prop.querySelector('.field').should.be.ok;
- });
+ it('Rendered correctly', function() {
+ var prop = view.el;
+ $fixture.get(0).querySelector('.property').should.be.ok;
+ prop.querySelector('.label').should.be.ok;
+ prop.querySelector('.field').should.be.ok;
+ });
- it('Select rendered', function() {
- var prop = view.el;
- prop.querySelector('select').should.be.ok;
- });
+ it('Select rendered', function() {
+ var prop = view.el;
+ prop.querySelector('select').should.be.ok;
+ });
- it('Options rendered', function() {
- var select = view.el.querySelector('select');
- select.children.length.should.equal(options.length);
- });
+ it('Options rendered', function() {
+ var select = view.el.querySelector('select');
+ select.children.length.should.equal(options.length);
+ });
- it('Options rendered correctly', function() {
- var select = view.el.querySelector('select');
- var children = select.children;
- children[0].value.should.equal(options[0].value);
- children[1].value.should.equal(options[1].value);
- children[0].textContent.should.equal(options[0].value);
- children[1].textContent.should.equal(options[1].name);
- children[0].getAttribute('style').should.equal(options[0].style);
- (children[1].getAttribute('style') == null).should.equal(true);
- });
+ it('Options rendered correctly', function() {
+ var select = view.el.querySelector('select');
+ var children = select.children;
+ children[0].value.should.equal(options[0].value);
+ children[1].value.should.equal(options[1].value);
+ children[0].textContent.should.equal(options[0].value);
+ children[1].textContent.should.equal(options[1].name);
+ children[0].getAttribute('style').should.equal(options[0].style);
+ (children[1].getAttribute('style') == null).should.equal(true);
+ });
- it('Input should exist', function() {
- view.$input.should.be.ok;
- });
+ it('Input should exist', function() {
+ view.$input.should.be.ok;
+ });
- it('Input value is empty', function() {
- view.model.get('value').should.be.empty;
- });
+ it('Input value is empty', function() {
+ view.model.get('value').should.be.empty;
+ });
- it('Update model on input change', function() {
- view.$input.val(propValue).trigger('change');
- view.model.get('value').should.equal(propValue);
- });
+ it('Update model on input change', function() {
+ view.$input.val(propValue).trigger('change');
+ view.model.get('value').should.equal(propValue);
+ });
- it('Update input on value change', function() {
- view.model.set('value', propValue);
- view.$input.val().should.equal(propValue);
- });
+ it('Update input on value change', function() {
+ view.model.set('value', propValue);
+ view.$input.val().should.equal(propValue);
+ });
- it('Update target on value change', function() {
- view.selectedComponent = component;
- view.model.set('value', propValue);
- var compStyle = view.selectedComponent.get('style');
- var assertStyle = {};
- assertStyle[propName] = propValue;
- compStyle.should.deep.equal(assertStyle);
- });
+ it('Update target on value change', function() {
+ view.selectedComponent = component;
+ view.model.set('value', propValue);
+ var compStyle = view.selectedComponent.get('style');
+ var assertStyle = {};
+ assertStyle[propName] = propValue;
+ compStyle.should.deep.equal(assertStyle);
+ });
- describe('With target setted', function() {
-
- beforeEach(function () {
- target.model = component;
- view = new PropertySelectView({
- model: model,
- propTarget: target
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Update value and input on target swap', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal(propValue);
- view.$input.val().should.equal(propValue);
- });
-
- it('Update value after multiple swaps', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- style[propName] = 'test2value';
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal('test2value');
- view.$input.val().should.equal('test2value');
- });
-
- })
-
- describe('Init property', function() {
-
- beforeEach(function () {
- component = new Component();
- model = new Property({
- type: 'select',
- list: options,
- defaults: defValue,
- property: propName
- });
- view = new PropertySelectView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Value as default', function() {
- view.model.get('value').should.equal(defValue);
- });
-
- it('Empty value as default', function() {
- options = [
- {value: 'test1value', name: 'test1'},
- {value: 'test2value', name: 'test2'},
- {value: '', name: 'TestDef'}
- ];
- component = new Component();
- model = new Property({
- type: 'select',
- list: options,
- defaults: '',
- property: 'emptyDefault'
- });
- view = new PropertySelectView({
- model: model
- });
- $fixture.html(view.render().el);
- view.$input.val().should.equal('');
- });
-
- it('Input value is as default', function() {
- view.$input.val().should.equal(defValue);
- });
+ describe('With target setted', function() {
+ beforeEach(function () {
+ target.model = component;
+ view = new PropertySelectView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Update value and input on target swap', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal(propValue);
+ view.$input.val().should.equal(propValue);
+ });
+
+ it('Update value after multiple swaps', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ style[propName] = 'test2value';
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal('test2value');
+ view.$input.val().should.equal('test2value');
+ });
+
+ })
+
+ describe('Init property', function() {
+
+ beforeEach(function () {
+ component = new Component();
+ model = new Property({
+ type: 'select',
+ list: options,
+ defaults: defValue,
+ property: propName
+ });
+ view = new PropertySelectView({
+ model: model
});
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Value as default', function() {
+ view.model.get('value').should.equal(defValue);
+ });
+
+ it('Empty value as default', function() {
+ options = [
+ {value: 'test1value', name: 'test1'},
+ {value: 'test2value', name: 'test2'},
+ {value: '', name: 'TestDef'}
+ ];
+ component = new Component();
+ model = new Property({
+ type: 'select',
+ list: options,
+ defaults: '',
+ property: 'emptyDefault'
+ });
+ view = new PropertySelectView({
+ model: model
+ });
+ $fixture.html(view.render().el);
+ view.$input.val().should.equal('');
+ });
+
+ it('Input value is as default', function() {
+ view.$input.val().should.equal(defValue);
+ });
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/PropertyStackView.js b/test/specs/style_manager/view/PropertyStackView.js
index d850181b5..5697ddd9b 100644
--- a/test/specs/style_manager/view/PropertyStackView.js
+++ b/test/specs/style_manager/view/PropertyStackView.js
@@ -1,350 +1,346 @@
-define(function(require, exports, module){
- 'use strict';
- var PropertyStackView = require('undefined');
- var Property = require('StyleManager/model/Property');
- var Component = require('DomComponents/model/Component');
-
- module.exports = {
- run : function(){
-
- describe('PropertyStackView', function() {
-
- var component;
- var $fixtures;
- var $fixture;
- var target;
- var model;
- var view;
- var propName = 'testprop';
- var propValue = 'test1value';
- var defValue = 'test2value';
- var layers = [
- {value: 'lval1'},
- {value: 'lval2 lval22'},
- {value: 'lval3 lval32 lval33'}
- ];
- var properties = [
- {property: 'subprop1'},
- {
- type: 'integer',
- property: 'subprop2',
- defaults: 0,
- units: ['%', 'px']
- },
- {
- type: 'select',
- property: 'subprop3',
- defaults: 'val2',
- list: [
- {value:'val1'},
- {value:'val2'},
- {value:'val3'},
- ]
- },
- ];
-
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
+const PropertyStackView = require('style_manager/view/PropertyStackView');
+const Property = require('style_manager/model/Property');
+const Component = require('dom_components/model/Component');
+
+module.exports = {
+ run : function(){
+
+ describe('PropertyStackView', function() {
+
+ var component;
+ var $fixtures;
+ var $fixture;
+ var target;
+ var model;
+ var view;
+ var propName = 'testprop';
+ var propValue = 'test1value';
+ var defValue = 'test2value';
+ var layers = [
+ {value: 'lval1'},
+ {value: 'lval2 lval22'},
+ {value: 'lval3 lval32 lval33'}
+ ];
+ var properties = [
+ {property: 'subprop1'},
+ {
+ type: 'integer',
+ property: 'subprop2',
+ defaults: 0,
+ units: ['%', 'px']
+ },
+ {
+ type: 'select',
+ property: 'subprop3',
+ defaults: 'val2',
+ list: [
+ {value:'val1'},
+ {value:'val2'},
+ {value:'val3'},
+ ]
+ },
+ ];
+
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
- beforeEach(function () {
- target = new Component();
- component = new Component();
- target.model = component;
- model = new Property({
- type: 'stack',
- property: propName,
- properties: properties
- });
- view = new PropertyStackView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+ beforeEach(function () {
+ target = new Component();
+ component = new Component();
+ target.model = component;
+ model = new Property({
+ type: 'stack',
+ property: propName,
+ properties: properties
+ });
+ view = new PropertyStackView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- afterEach(function () {
- //view.remove(); // strange errors ???
- });
+ afterEach(function () {
+ //view.remove(); // strange errors ???
+ });
- after(function () {
- $fixture.remove();
- delete component;
- delete view;
- delete model;
- });
+ after(function () {
+ $fixture.remove();
+ component = null;
+ view = null;
+ model = null;
+ });
- it('Rendered correctly', function() {
- var prop = view.el;
- $fixture.get(0).querySelector('.property').should.be.ok;
- prop.querySelector('.label').should.be.ok;
- prop.querySelector('.field').should.be.ok;
- prop.querySelector('#add').should.be.ok;
- });
+ it('Rendered correctly', function() {
+ var prop = view.el;
+ $fixture.get(0).querySelector('.property').should.be.ok;
+ prop.querySelector('.label').should.be.ok;
+ prop.querySelector('.field').should.be.ok;
+ prop.querySelector('#add').should.be.ok;
+ });
- it('Layers rendered', function() {
- view.el.querySelector('.layers').should.be.ok;
- });
+ it('Layers rendered', function() {
+ view.el.querySelector('.layers').should.be.ok;
+ });
- it('Layers should exist', function() {
- view.$props.should.be.ok;
- });
+ it('Layers should exist', function() {
+ view.$props.should.be.ok;
+ });
- it('Layers rendered correctly', function() {
- var children = view.$props.get(0).children;
- children.length.should.equal(properties.length + 1);
- children[0].id.should.equal(properties[0].property);
- children[1].id.should.equal(properties[1].property);
- children[2].id.should.equal(properties[2].property);
- });
+ it('Layers rendered correctly', function() {
+ var children = view.$props.get(0).children;
+ children.length.should.equal(properties.length + 1);
+ children[0].id.should.equal(properties[0].property);
+ children[1].id.should.equal(properties[1].property);
+ children[2].id.should.equal(properties[2].property);
+ });
- it('Input value is empty', function() {
- view.model.get('value').should.be.empty;
- });
+ it('Input value is empty', function() {
+ view.model.get('value').should.be.empty;
+ });
- it('Layers container is empty', function() {
- var layers = view.el.querySelector('.layers');
- layers.innerHTML.should.be.empty;
- });
+ it('Layers container is empty', function() {
+ var layers = view.el.querySelector('.layers');
+ layers.innerHTML.should.be.empty;
+ });
- describe('With layers', function() {
-
- beforeEach(function () {
- model = new Property({
- type: 'stack',
- property: propName,
- properties: properties,
- });
- view = new PropertyStackView({
- model: model,
- propTarget: target
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- model.get('layers').add(layers);
- });
-
- it('Layers inserted', function() {
- view.getLayers().length.should.equal(layers.length);
- });
-
- it('Get value on index', function() {
- view.model.set('stackIndex', 1);
- view.valueOnIndex(1).should.equal('lval22');
- });
-
- it('createValue merges layers', function() {
- view.createValue().should.equal('lval1, lval2 lval22, lval3 lval32 lval33');
- });
-
- it('Add layer', function() {
- view.addLayer();
- view.getLayers().length.should.equal(layers.length+1);
- });
+ describe('With layers', function() {
+ beforeEach(function () {
+ model = new Property({
+ type: 'stack',
+ property: propName,
+ properties: properties,
});
+ view = new PropertyStackView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ model.get('layers').add(layers);
+ });
+
+ it('Layers inserted', function() {
+ view.getLayers().length.should.equal(layers.length);
+ });
+
+ it('Get value on index', function() {
+ view.model.set('stackIndex', 1);
+ view.valueOnIndex(1).should.equal('lval22');
+ });
+
+ it('createValue merges layers', function() {
+ view.createValue().should.equal('lval1, lval2 lval22, lval3 lval32 lval33');
+ });
- describe('With target setted', function() {
-
- var prop2Val;
- var prop3Val;
- var prop2Unit;
- var finalResult;
- var $prop1;
- var $prop2;
- var $prop3;
-
- beforeEach(function () {
- model = new Property({
- type: 'stack',
- property: propName,
- properties: properties
- });
- view = new PropertyStackView({
- model: model,
- propTarget: target
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- prop3Val = properties[2].list[2].value;
- prop2Val = properties[1].defaults;
- prop2Unit = properties[1].units[0];
- finalResult = propValue + ' ' + prop2Val + prop2Unit +' ' + prop3Val;
- view.addLayer();
- $prop1 = view.$props.find('#' + properties[0].property + ' input');
- $prop2 = view.$props.find('#' + properties[1].property + ' input');
- $prop3 = view.$props.find('#' + properties[2].property + ' select');
- });
-
- it('Update model on input change', function() {
- $prop1.val(propValue).trigger('change');
- $prop3.val(prop3Val).trigger('change');
- view.model.get('value').should.equal(finalResult);
- });
-
- it('Update value on models change', function() {
- view.model.get('properties').at(0).set('value', propValue);
- view.model.get('properties').at(2).set('value', prop3Val);
- view.model.get('value').should.equal(finalResult);
- });
-
- it('Update target on value change', function() {
- $prop1.val(propValue).trigger('change');
- var compStyle = view.getTarget().get('style');
- var assertStyle = {};
- assertStyle[propName] = propValue + ' 0% val2';
- compStyle.should.deep.equal(assertStyle);
- });
-
- it('Update value and input on target swap', function() {
- var style = {};
- var finalResult2 = 'A B C';
- style[propName] = finalResult + ', ' + finalResult2;
- component.set('style', style);
- view.propTarget.trigger('update');
- var layers = view.getLayers();
- layers.at(0).get('value').should.equal(finalResult);
- layers.at(1).get('value').should.equal(finalResult2);
- });
-
- it('Update value after multiple swaps', function() {
- var style = {};
- var finalResult2 = 'A2 B2 C2';
- style[propName] = finalResult;
- component.set('style', style);
- view.propTarget.trigger('update');
- style[propName] = finalResult + ', ' + finalResult2;
- component.set('style', style);
- view.propTarget.trigger('update');
- var layers = view.getLayers();
- layers.at(0).get('value').should.equal(finalResult);
- layers.at(1).get('value').should.equal(finalResult2);
- });
-
- it('The value is correctly extracted from the composite string', function() {
- var style = {};
- style[propName] = 'value1 value2, value3 value4';
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.set('stackIndex', 1);
- view.valueOnIndex(0).should.equal('value3');
- view.valueOnIndex(1).should.equal('value4');
- (view.valueOnIndex(2) === null).should.equal(true);
- });
-
- it('The value is correctly extracted from the string with functions', function() {
- var style = {};
- style[propName] = 'func(a1a, s2a,d3a) value1 value2, func(4ddb, aAS5b, sS.6b) value3';
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.set('stackIndex', 1);
- view.valueOnIndex(0).should.equal('func(4ddb,aAS5b,sS.6b)');
- view.valueOnIndex(1).should.equal('value3');
- (view.valueOnIndex(2) === null).should.equal(true);
- });
-
- it('Build value from properties', function() {
- view.model.get('properties').at(0).set('value', propValue);
- view.model.get('properties').at(2).set('value', prop3Val);
- view.build().should.equal(finalResult);
- });
+ it('Add layer', function() {
+ view.addLayer();
+ view.getLayers().length.should.equal(layers.length+1);
+ });
+ });
+
+ describe('With target setted', function() {
+
+ var prop2Val;
+ var prop3Val;
+ var prop2Unit;
+ var finalResult;
+ var $prop1;
+ var $prop2;
+ var $prop3;
+
+ beforeEach(function () {
+ model = new Property({
+ type: 'stack',
+ property: propName,
+ properties: properties
});
+ view = new PropertyStackView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ prop3Val = properties[2].list[2].value;
+ prop2Val = properties[1].defaults;
+ prop2Unit = properties[1].units[0];
+ finalResult = propValue + ' ' + prop2Val + prop2Unit +' ' + prop3Val;
+ view.addLayer();
+ $prop1 = view.$props.find('#' + properties[0].property + ' input');
+ $prop2 = view.$props.find('#' + properties[1].property + ' input');
+ $prop3 = view.$props.find('#' + properties[2].property + ' select');
+ });
+
+ it('Update model on input change', function() {
+ $prop1.val(propValue).trigger('change');
+ $prop3.val(prop3Val).trigger('change');
+ view.model.get('value').should.equal(finalResult);
+ });
+
+ it('Update value on models change', function() {
+ view.model.get('properties').at(0).set('value', propValue);
+ view.model.get('properties').at(2).set('value', prop3Val);
+ view.model.get('value').should.equal(finalResult);
+ });
+
+ it('Update target on value change', function() {
+ $prop1.val(propValue).trigger('change');
+ var compStyle = view.getTarget().get('style');
+ var assertStyle = {};
+ assertStyle[propName] = propValue + ' 0% val2';
+ compStyle.should.deep.equal(assertStyle);
+ });
+
+ it('Update value and input on target swap', function() {
+ var style = {};
+ var finalResult2 = 'A B C';
+ style[propName] = finalResult + ', ' + finalResult2;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ var layers = view.getLayers();
+ layers.at(0).get('value').should.equal(finalResult);
+ layers.at(1).get('value').should.equal(finalResult2);
+ });
+
+ it('Update value after multiple swaps', function() {
+ var style = {};
+ var finalResult2 = 'A2 B2 C2';
+ style[propName] = finalResult;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ style[propName] = finalResult + ', ' + finalResult2;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ var layers = view.getLayers();
+ layers.at(0).get('value').should.equal(finalResult);
+ layers.at(1).get('value').should.equal(finalResult2);
+ });
+
+ it('The value is correctly extracted from the composite string', function() {
+ var style = {};
+ style[propName] = 'value1 value2, value3 value4';
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.set('stackIndex', 1);
+ view.valueOnIndex(0).should.equal('value3');
+ view.valueOnIndex(1).should.equal('value4');
+ (view.valueOnIndex(2) === null).should.equal(true);
+ });
+
+ it('The value is correctly extracted from the string with functions', function() {
+ var style = {};
+ style[propName] = 'func(a1a, s2a,d3a) value1 value2, func(4ddb, aAS5b, sS.6b) value3';
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.set('stackIndex', 1);
+ view.valueOnIndex(0).should.equal('func(4ddb,aAS5b,sS.6b)');
+ view.valueOnIndex(1).should.equal('value3');
+ (view.valueOnIndex(2) === null).should.equal(true);
+ });
+
+ it('Build value from properties', function() {
+ view.model.get('properties').at(0).set('value', propValue);
+ view.model.get('properties').at(2).set('value', prop3Val);
+ view.build().should.equal(finalResult);
+ });
- describe('Detached with target setted', function() {
-
- var prop2Val;
- var prop3Val;
- var prop2Unit;
- var finalResult;
- var $prop1;
- var $prop2;
- var $prop3;
- var compStyle = {
- subprop1: '1px, 20px, 30px',
- subprop2: 'A, B, C',
- subprop3: 'W, X, Y',
- subprop555: 'T, T, T',
- };
-
- beforeEach(function () {
- model = new Property({
- type: 'stack',
- property: propName,
- properties: properties,
- detached: true,
- });
- view = new PropertyStackView({
- model: model,
- propTarget: target
- });
- $fixture.html(view.render().el);
- prop3Val = properties[2].list[2].value;
- prop2Val = properties[1].defaults;
- prop2Unit = properties[1].units[0];
- finalResult = propValue + ' ' + prop2Val + prop2Unit +' ' + prop3Val;
- view.addLayer();
- $prop1 = view.$props.find('#' + properties[0].property + ' input');
- $prop2 = view.$props.find('#' + properties[1].property + ' input');
- $prop3 = view.$props.find('#' + properties[2].property + ' select');
- });
-
- it('Returns correctly layers array from target', function() {
- component.set('style', compStyle);
- var result = [{
- subprop1: '1px',
- subprop2: 'A',
- subprop3: 'W',
- },{
- subprop1: '20px',
- subprop2: 'B',
- subprop3: 'X',
- },{
- subprop1: '30px',
- subprop2: 'C',
- subprop3: 'Y',
- }];
- view.getLayersFromTarget().should.deep.equal(result);
- });
-
- it('Update target on detached value change', function() {
- $prop1.val(propValue).trigger('change');
- var compStyle = view.getTarget().get('style');
- var assertStyle = {};
- assertStyle[properties[0].property] = $prop1.val();
- assertStyle[properties[1].property] = '0%';
- assertStyle[properties[2].property] = properties[2].defaults;
- compStyle.should.deep.equal(assertStyle);
- });
-
- it('Update value and input on target swap', function() {
- var style = {};
- component.set('style', compStyle);
- view.propTarget.trigger('update');
- var layers = view.getLayers();
- layers.length.should.equal(3);
- layers.at(0).get('values').should.deep.equal({
- subprop1: '1px',
- subprop2: 'A',
- subprop3: 'W',
- });
- layers.at(1).get('values').should.deep.equal({
- subprop1: '20px',
- subprop2: 'B',
- subprop3: 'X',
- });
- layers.at(2).get('values').should.deep.equal({
- subprop1: '30px',
- subprop2: 'C',
- subprop3: 'Y',
- });
- });
+ });
+ describe('Detached with target setted', function() {
+
+ var prop2Val;
+ var prop3Val;
+ var prop2Unit;
+ var finalResult;
+ var $prop1;
+ var $prop2;
+ var $prop3;
+ var compStyle = {
+ subprop1: '1px, 20px, 30px',
+ subprop2: 'A, B, C',
+ subprop3: 'W, X, Y',
+ subprop555: 'T, T, T',
+ };
+
+ beforeEach(function () {
+ model = new Property({
+ type: 'stack',
+ property: propName,
+ properties: properties,
+ detached: true,
+ });
+ view = new PropertyStackView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.html(view.render().el);
+ prop3Val = properties[2].list[2].value;
+ prop2Val = properties[1].defaults;
+ prop2Unit = properties[1].units[0];
+ finalResult = propValue + ' ' + prop2Val + prop2Unit +' ' + prop3Val;
+ view.addLayer();
+ $prop1 = view.$props.find('#' + properties[0].property + ' input');
+ $prop2 = view.$props.find('#' + properties[1].property + ' input');
+ $prop3 = view.$props.find('#' + properties[2].property + ' select');
+ });
+
+ it('Returns correctly layers array from target', function() {
+ component.set('style', compStyle);
+ var result = [{
+ subprop1: '1px',
+ subprop2: 'A',
+ subprop3: 'W',
+ },{
+ subprop1: '20px',
+ subprop2: 'B',
+ subprop3: 'X',
+ },{
+ subprop1: '30px',
+ subprop2: 'C',
+ subprop3: 'Y',
+ }];
+ view.getLayersFromTarget().should.deep.equal(result);
+ });
+
+ it('Update target on detached value change', function() {
+ $prop1.val(propValue).trigger('change');
+ var compStyle = view.getTarget().get('style');
+ var assertStyle = {};
+ assertStyle[properties[0].property] = $prop1.val();
+ assertStyle[properties[1].property] = '0%';
+ assertStyle[properties[2].property] = properties[2].defaults;
+ compStyle.should.deep.equal(assertStyle);
+ });
+
+ it('Update value and input on target swap', function() {
+ var style = {};
+ component.set('style', compStyle);
+ view.propTarget.trigger('update');
+ var layers = view.getLayers();
+ layers.length.should.equal(3);
+ layers.at(0).get('values').should.deep.equal({
+ subprop1: '1px',
+ subprop2: 'A',
+ subprop3: 'W',
+ });
+ layers.at(1).get('values').should.deep.equal({
+ subprop1: '20px',
+ subprop2: 'B',
+ subprop3: 'X',
+ });
+ layers.at(2).get('values').should.deep.equal({
+ subprop1: '30px',
+ subprop2: 'C',
+ subprop3: 'Y',
});
+ });
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/PropertyView.js b/test/specs/style_manager/view/PropertyView.js
index 8e04c6192..c41ea4bf8 100644
--- a/test/specs/style_manager/view/PropertyView.js
+++ b/test/specs/style_manager/view/PropertyView.js
@@ -1,238 +1,234 @@
-define(function(require, exports, module){
- 'use strict';
- var PropertyView = require('undefined');
- var Property = require('StyleManager/model/Property');
- var Component = require('DomComponents/model/Component');
-
- module.exports = {
- run : function(){
-
- describe('PropertyView', function() {
-
- var component;
- var $fixtures;
- var $fixture;
- var target;
- var model;
- var view;
- var propName = 'testprop';
- var propValue = 'testvalue';
- var defValue = 'testDefault';
-
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
-
- beforeEach(function () {
- target = new Component();
- component = new Component();
- model = new Property({property: propName});
- view = new PropertyView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+const PropertyView = require('style_manager/view/PropertyView');
+const Property = require('style_manager/model/Property');
+const Component = require('dom_components/model/Component');
+
+module.exports = {
+ run : function(){
+
+ describe('PropertyView', function() {
+
+ var component;
+ var $fixtures;
+ var $fixture;
+ var target;
+ var model;
+ var view;
+ var propName = 'testprop';
+ var propValue = 'testvalue';
+ var defValue = 'testDefault';
+
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
- afterEach(function () {
- //view.remove(); // strange errors ???
- });
+ beforeEach(function () {
+ target = new Component();
+ component = new Component();
+ model = new Property({property: propName});
+ view = new PropertyView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- after(function () {
- $fixture.remove();
- delete component;
- });
+ afterEach(function () {
+ //view.remove(); // strange errors ???
+ });
- it('Rendered correctly', function() {
- var prop = view.el;
- $fixture.get(0).querySelector('.property').should.be.ok;
- prop.querySelector('.label').should.be.ok;
- prop.querySelector('.field').should.be.ok;
- });
+ after(function () {
+ $fixture.remove();
+ component = null;
+ });
- it('Input should exist', function() {
- view.$input.should.be.ok;
- });
+ it('Rendered correctly', function() {
+ var prop = view.el;
+ $fixture.get(0).querySelector('.property').should.be.ok;
+ prop.querySelector('.label').should.be.ok;
+ prop.querySelector('.field').should.be.ok;
+ });
- it('Input value is empty', function() {
- view.model.get('value').should.be.empty;
- view.$input.val().should.be.empty;
- });
+ it('Input should exist', function() {
+ view.$input.should.be.ok;
+ });
- it('Model not change without update trigger', function() {
- view.$input.val(propValue);
- view.model.get('value').should.be.empty;
- });
+ it('Input value is empty', function() {
+ view.model.get('value').should.be.empty;
+ view.$input.val().should.be.empty;
+ });
- // Tests valueUpdated()
- it('Update model on input change', function() {
- view.$input.val(propValue).trigger('change');
- view.model.get('value').should.equal(propValue);
- });
+ it('Model not change without update trigger', function() {
+ view.$input.val(propValue);
+ view.model.get('value').should.be.empty;
+ });
- // Tests getValueForTarget()
- it('Get value for target', function() {
- view.model.set('value', propValue);
- view.getValueForTarget().should.equal(propValue);
- });
+ // Tests valueUpdated()
+ it('Update model on input change', function() {
+ view.$input.val(propValue).trigger('change');
+ view.model.get('value').should.equal(propValue);
+ });
- // Tests valueChanged() -> ...
- it('Update input on value change', function() {
- view.model.set('value', propValue);
- view.$input.val().should.equal(propValue);
- });
+ // Tests getValueForTarget()
+ it('Get value for target', function() {
+ view.model.set('value', propValue);
+ view.getValueForTarget().should.equal(propValue);
+ });
- it('Update target on value change', function() {
- view.selectedComponent = component;
- view.model.set('value', propValue);
- var compStyle = view.selectedComponent.get('style');
- var assertStyle = {};
- assertStyle[propName] = propValue;
- compStyle.should.deep.equal(assertStyle);
- });
+ // Tests valueChanged() -> ...
+ it('Update input on value change', function() {
+ view.model.set('value', propValue);
+ view.$input.val().should.equal(propValue);
+ });
- it('Update target on value change with functionName', function() {
- view.selectedComponent = component;
- view.model.set('functionName', 'testfunc');
- view.model.set('value', propValue);
- var compStyle = view.selectedComponent.get('style');
- var assertStyle = {};
- assertStyle[propName] = 'testfunc(' + propValue + ')';
- compStyle.should.deep.equal(assertStyle);
- });
+ it('Update target on value change', function() {
+ view.selectedComponent = component;
+ view.model.set('value', propValue);
+ var compStyle = view.selectedComponent.get('style');
+ var assertStyle = {};
+ assertStyle[propName] = propValue;
+ compStyle.should.deep.equal(assertStyle);
+ });
- it('Clean target from the property if its value is empty', function() {
- view.selectedComponent = component;
- view.model.set('value', propValue);
- view.model.set('value', '');
- var compStyle = view.selectedComponent.get('style');
- compStyle.should.deep.equal({});
- });
+ it('Update target on value change with functionName', function() {
+ view.selectedComponent = component;
+ view.model.set('functionName', 'testfunc');
+ view.model.set('value', propValue);
+ var compStyle = view.selectedComponent.get('style');
+ var assertStyle = {};
+ assertStyle[propName] = 'testfunc(' + propValue + ')';
+ compStyle.should.deep.equal(assertStyle);
+ });
- it('Check stylable element', function() {
- view.selectedComponent = component;
- view.isTargetStylable().should.equal(true);
- component.set('stylable', false);
- view.isTargetStylable().should.equal(false);
- component.set('stylable', [propName]);
- view.isTargetStylable().should.equal(true);
- component.set('stylable', ['test1', propName]);
- view.isTargetStylable().should.equal(true);
- component.set('stylable', ['test1', 'test2']);
- view.isTargetStylable().should.equal(false);
- });
+ it('Clean target from the property if its value is empty', function() {
+ view.selectedComponent = component;
+ view.model.set('value', propValue);
+ view.model.set('value', '');
+ var compStyle = view.selectedComponent.get('style');
+ compStyle.should.deep.equal({});
+ });
- it('Target style is empty without values', function() {
- view.selectedComponent = component;
- view.getComponentValue().should.be.empty;
- });
+ it('Check stylable element', function() {
+ view.selectedComponent = component;
+ view.isTargetStylable().should.equal(true);
+ component.set('stylable', false);
+ view.isTargetStylable().should.equal(false);
+ component.set('stylable', [propName]);
+ view.isTargetStylable().should.equal(true);
+ component.set('stylable', ['test1', propName]);
+ view.isTargetStylable().should.equal(true);
+ component.set('stylable', ['test1', 'test2']);
+ view.isTargetStylable().should.equal(false);
+ });
- it('Target style is correct', function() {
- view.selectedComponent = component;
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.getComponentValue().should.equal(propValue);
- });
+ it('Target style is empty without values', function() {
+ view.selectedComponent = component;
+ view.getComponentValue().should.be.empty;
+ });
- it('Target style is empty with an other style', function() {
- view.selectedComponent = component;
- var style = {};
- style[propName + '2'] = propValue;
- component.set('style', style);
- view.getComponentValue().should.be.empty;
- });
+ it('Target style is correct', function() {
+ view.selectedComponent = component;
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.getComponentValue().should.equal(propValue);
+ });
- it('Fetch value from function', function() {
- view.selectedComponent = component;
- var style = {};
- style[propName] = 'testfun(' + propValue + ')';
- component.set('style', style);
- view.model.set('functionName', 'testfun');
- view.getComponentValue().should.equal(propValue);
- });
+ it('Target style is empty with an other style', function() {
+ view.selectedComponent = component;
+ var style = {};
+ style[propName + '2'] = propValue;
+ component.set('style', style);
+ view.getComponentValue().should.be.empty;
+ });
- describe('With target setted', function() {
-
- beforeEach(function () {
- target.model = component;
- view = new PropertyView({
- model: model,
- propTarget: target
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('updateTargetStyle', function() {
- view.updateTargetStyle(propValue);
- var style = {};
- style[propName] = propValue;
- component.get('style').should.deep.equal(style);
- });
-
- it('updateTargetStyle with custom property', function() {
- view.updateTargetStyle(propValue, propName + '2');
- var style = {};
- style[propName + '2'] = propValue;
- component.get('style').should.deep.equal(style);
- });
-
- it('Update value and input on target swap', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal(propValue);
- view.$input.val().should.equal(propValue);
- });
-
- it('Update value after multiple swaps', function() {
- var style = {};
- style[propName] = propValue;
- component.set('style', style);
- view.propTarget.trigger('update');
- style[propName] = propValue + '2';
- component.set('style', style);
- view.propTarget.trigger('update');
- view.model.get('value').should.equal(propValue + '2');
- view.$input.val().should.equal(propValue + '2');
- });
-
- })
-
- describe('Init property', function() {
-
- beforeEach(function () {
- component = new Component();
- model = new Property({
- property: propName,
- defaults: defValue
- });
- view = new PropertyView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- it('Value as default', function() {
- view.model.get('value').should.equal(defValue);
- });
-
- it('Placeholder as default', function() {
- view.$input.attr('placeholder').should.equal(defValue);
- });
-
- it('Input value is empty', function() {
- view.$input.val().should.equal(defValue);
- });
+ it('Fetch value from function', function() {
+ view.selectedComponent = component;
+ var style = {};
+ style[propName] = 'testfun(' + propValue + ')';
+ component.set('style', style);
+ view.model.set('functionName', 'testfun');
+ view.getComponentValue().should.equal(propValue);
+ });
- });
+ describe('With target setted', function() {
+
+ beforeEach(function () {
+ target.model = component;
+ view = new PropertyView({
+ model: model,
+ propTarget: target
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('updateTargetStyle', function() {
+ view.updateTargetStyle(propValue);
+ var style = {};
+ style[propName] = propValue;
+ component.get('style').should.deep.equal(style);
+ });
+
+ it('updateTargetStyle with custom property', function() {
+ view.updateTargetStyle(propValue, propName + '2');
+ var style = {};
+ style[propName + '2'] = propValue;
+ component.get('style').should.deep.equal(style);
+ });
+
+ it('Update value and input on target swap', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal(propValue);
+ view.$input.val().should.equal(propValue);
+ });
+
+ it('Update value after multiple swaps', function() {
+ var style = {};
+ style[propName] = propValue;
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ style[propName] = propValue + '2';
+ component.set('style', style);
+ view.propTarget.trigger('update');
+ view.model.get('value').should.equal(propValue + '2');
+ view.$input.val().should.equal(propValue + '2');
+ });
+
+ })
+
+ describe('Init property', function() {
+
+ beforeEach(function () {
+ component = new Component();
+ model = new Property({
+ property: propName,
+ defaults: defValue
+ });
+ view = new PropertyView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ it('Value as default', function() {
+ view.model.get('value').should.equal(defValue);
+ });
+
+ it('Placeholder as default', function() {
+ view.$input.attr('placeholder').should.equal(defValue);
+ });
+
+ it('Input value is empty', function() {
+ view.$input.val().should.equal(defValue);
+ });
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/SectorView.js b/test/specs/style_manager/view/SectorView.js
index c4e2a9023..1029df4eb 100644
--- a/test/specs/style_manager/view/SectorView.js
+++ b/test/specs/style_manager/view/SectorView.js
@@ -1,109 +1,105 @@
-define(function(require, exports, module){
- 'use strict';
- var SectorView = require('undefined');
- var Sector = require('StyleManager/model/Sector');
+const SectorView = require('style_manager/view/SectorView');
+const Sector = require('style_manager/model/Sector');
- module.exports = {
- run : function(){
+module.exports = {
+ run : function(){
- describe('SectorView', function() {
+ describe('SectorView', function() {
- var $fixtures;
- var $fixture;
- var model;
- var view;
+ var $fixtures;
+ var $fixture;
+ var model;
+ var view;
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
-
- beforeEach(function () {
- model = new Sector();
- view = new SectorView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
- afterEach(function () {
- view.remove();
- });
+ beforeEach(function () {
+ model = new Sector();
+ view = new SectorView({
+ model: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
- after(function () {
- $fixture.remove();
- });
+ afterEach(function () {
+ view.remove();
+ });
- it('Rendered correctly', function() {
- var sector = view.el;
- sector.should.be.ok;
- sector.querySelector('.title').should.be.ok;
- var props = sector.querySelector('.properties');
- props.should.be.ok;
- sector.classList.contains('open').should.equal(true);
- });
+ after(function () {
+ $fixture.remove();
+ });
- it('No properties', function() {
- var props = view.el.querySelector('.properties');
- props.innerHTML.should.equal('
');
- });
+ it('Rendered correctly', function() {
+ var sector = view.el;
+ sector.should.be.ok;
+ sector.querySelector('.title').should.be.ok;
+ var props = sector.querySelector('.properties');
+ props.should.be.ok;
+ sector.classList.contains('open').should.equal(true);
+ });
- it('Update on open', function() {
- var sector = view.el;
- var props = sector.querySelector('.properties');
- model.set('open', false);
- sector.classList.contains('open').should.equal(false);
- props.style.display.should.equal('none');
- });
+ it('No properties', function() {
+ var props = view.el.querySelector('.properties');
+ props.innerHTML.should.equal('
');
+ });
- it('Toggle on click', function() {
- var sector = view.el;
- view.$el.find('.title').click();
- sector.classList.contains('open').should.equal(false);
- });
+ it('Update on open', function() {
+ var sector = view.el;
+ var props = sector.querySelector('.properties');
+ model.set('open', false);
+ sector.classList.contains('open').should.equal(false);
+ props.style.display.should.equal('none');
+ });
- describe('Init with options', function() {
-
- beforeEach(function () {
- model = new Sector({
- open: false,
- name: 'TestName',
- properties: [
- {type:'integer'},
- {type:'integer'},
- {type:'integer'},
- ]
- });
- view = new SectorView({
- model: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- afterEach(function () {
- view.remove();
- });
-
- it('Rendered correctly2', function() {
- var sector = view.el;
- var props = sector.querySelector('.properties');
- sector.querySelector('.title').innerHTML.should.contain('TestName');
- props.should.be.ok;
- sector.classList.contains('open').should.equal(false);
- props.style.display.should.equal('none');
- });
-
- it('Has properties', function() {
- var props = view.el.querySelector('.properties');
- props.children.length.should.equal(4); // Last one is 'clear' element
- });
+ it('Toggle on click', function() {
+ var sector = view.el;
+ view.$el.find('.title').click();
+ sector.classList.contains('open').should.equal(false);
+ });
+ describe('Init with options', function() {
+
+ beforeEach(function () {
+ model = new Sector({
+ open: false,
+ name: 'TestName',
+ properties: [
+ {type:'integer'},
+ {type:'integer'},
+ {type:'integer'},
+ ]
+ });
+ view = new SectorView({
+ model: model
});
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ afterEach(function () {
+ view.remove();
+ });
+
+ it('Rendered correctly2', function() {
+ var sector = view.el;
+ var props = sector.querySelector('.properties');
+ sector.querySelector('.title').innerHTML.should.contain('TestName');
+ props.should.be.ok;
+ sector.classList.contains('open').should.equal(false);
+ props.style.display.should.equal('none');
+ });
+
+ it('Has properties', function() {
+ var props = view.el.querySelector('.properties');
+ props.children.length.should.equal(4); // Last one is 'clear' element
+ });
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};
diff --git a/test/specs/style_manager/view/SectorsView.js b/test/specs/style_manager/view/SectorsView.js
index 2db86a9b3..b07f738a4 100644
--- a/test/specs/style_manager/view/SectorsView.js
+++ b/test/specs/style_manager/view/SectorsView.js
@@ -1,51 +1,47 @@
-define(function(require, exports, module){
- 'use strict';
- var SectorsView = require('undefined');
- var Sectors = require('StyleManager/model/Sectors');
-
- module.exports = {
- run : function(){
-
- describe('SectorsView', function() {
-
- var $fixtures;
- var $fixture;
- var model;
- var view;
-
- before(function () {
- $fixtures = $("#fixtures");
- $fixture = $('
');
- });
-
- beforeEach(function () {
- model = new Sectors([]);
- view = new SectorsView({
- collection: model
- });
- $fixture.empty().appendTo($fixtures);
- $fixture.html(view.render().el);
- });
-
- afterEach(function () {
- view.collection.reset();
- });
-
- after(function () {
- $fixture.remove();
- });
-
- it("Collection is empty", function (){
- view.el.innerHTML.should.be.empty;
- });
-
- it("Add new sectors", function (){
- view.collection.add([{}, {}]);
- view.el.children.length.should.equal(2);
- });
+const SectorsView = require('style_manager/view/SectorsView');
+const Sectors = require('style_manager/model/Sectors');
+module.exports = {
+ run : function(){
+
+ describe('SectorsView', function() {
+
+ var $fixtures;
+ var $fixture;
+ var model;
+ var view;
+
+ before(function () {
+ $fixtures = $("#fixtures");
+ $fixture = $('
');
+ });
+
+ beforeEach(function () {
+ model = new Sectors([]);
+ view = new SectorsView({
+ collection: model
+ });
+ $fixture.empty().appendTo($fixtures);
+ $fixture.html(view.render().el);
+ });
+
+ afterEach(function () {
+ view.collection.reset();
+ });
+
+ after(function () {
+ $fixture.remove();
+ });
+
+ it("Collection is empty", function (){
+ view.el.innerHTML.should.be.empty;
+ });
+
+ it("Add new sectors", function (){
+ view.collection.add([{}, {}]);
+ view.el.children.length.should.equal(2);
});
- }
- };
-});
\ No newline at end of file
+ });
+ }
+};