Permalink
Browse files

Adjust tests

  • Loading branch information...
1 parent 15f234c commit ece6393b3b40e02307fd773e748d6192e2db6061 @artf committed Jan 11, 2017
View
@@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Open source Web Template Editor",
- "version": "0.3.36",
+ "version": "0.3.37",
"author": "Artur Arseniev",
"homepage": "http://grapesjs.com",
"main": [
View
Oops, something went wrong.
View
@@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Open source Web Template Editor",
- "version": "0.3.36",
+ "version": "0.3.37",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",
@@ -85,6 +85,7 @@ define(['backbone', 'text!./templates/inputNumber.html'],
getInputEl: function() {
if(!this.inputEl) {
this.inputEl = $('<input>', {
+ type: 'text',
class: this.inputCls,
placeholder: this.model.get('defaults')
});
@@ -183,11 +184,12 @@ define(['backbone', 'text!./templates/inputNumber.html'],
* @return {Object} Validated string
*/
validateInputValue: function(value, opts) {
- var unit = '';
- var val = value;
var force = 0;
var opt = opts || {};
var model = this.model;
+ var val = value || model.get('defaults');
+ var units = model.get('units') || [];
+ var unit = model.get('unit') || (units.length && units[0]) || '';
var max = model.get('max');
var min = model.get('min');
@@ -202,13 +204,13 @@ define(['backbone', 'text!./templates/inputNumber.html'],
unit = '';
force = 1;
} else {
- // Make it suitable for replace
- val += '';
+ var valCopy = val + '';
+ val += ''; // Make it suitable for replace
val = parseFloat(val.replace(',', '.'));
val = !isNaN(val) ? val : model.get('defaults');
- var uN = value.replace(val, '');
+ var uN = valCopy.replace(val, '');
// Check if exists as unit
- if(_.indexOf(model.get('units'), uN) >= 0)
+ if(_.indexOf(units, uN) >= 0)
unit = uN;
}
}
@@ -24,13 +24,17 @@ define(['backbone','./PropertyView', 'Abstract/ui/InputNumber'],
});
this.input = inputNumber.render();
this.$el.append(this.input.$el);
+ this.$input = this.input.inputEl;
+ this.$unit = this.input.unitEl;
}
- this.input.setValue(this.componentValue, {silent: 1});
+ this.setValue(this.componentValue);
},
renderTemplate: function(){},
- setValue: function() {},
+ setValue: function(value) {
+ this.input.setValue(value, {silent: 1});
+ },
});
});
@@ -315,11 +315,12 @@ define([path + 'Sector',
obj.build('left').should.deep.equal([res]);
});
- it('Build width e height family', function() {
+ it('Build width and height family', function() {
var res = {
type: 'integer',
units: ['px','%'],
defaults: 'auto',
+ fixedValues: ['initial', 'inherit', 'auto'],
min: 0,
}
res.property = 'width';
@@ -375,21 +376,25 @@ define([path + 'Sector',
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,
@@ -20,7 +20,7 @@ define([path + 'PropertyIntegerView', 'StyleManager/model/Property', 'DomCompone
var defValue = 'test2value';
var units = ['px', '%', 'em'];
var minValue = -15;
- var maxValue = 15;
+ var maxValue = 75;
var unitsElSel = '.field-units select';
before(function () {
@@ -179,7 +179,7 @@ define([path + 'PropertyIntegerView', 'StyleManager/model/Property', 'DomCompone
});
it('Value as default', function() {
- view.model.get('value').should.equal(intValue);
+ view.model.get('value').should.equal(parseInt(intValue));
view.model.get('unit').should.equal(units[1]);
});

0 comments on commit ece6393

Please sign in to comment.