Browse Source

Update property view tests

pull/187/head
Artur Arseniev 9 years ago
parent
commit
3c8e39c29a
  1. 2
      test/specs/style_manager/index.js
  2. 62
      test/specs/style_manager/view/PropertyView.js

2
test/specs/style_manager/index.js

@ -181,8 +181,8 @@ describe.only('StyleManager', function() {
Models.run(); Models.run();
SectorView.run(); SectorView.run();
SectorsView.run(); SectorsView.run();
/*
PropertyView.run(); PropertyView.run();
/*
PropertySelectView.run(); PropertySelectView.run();
PropertyRadioView.run(); PropertyRadioView.run();
PropertyIntegerView.run(); PropertyIntegerView.run();

62
test/specs/style_manager/view/PropertyView.js

@ -44,41 +44,41 @@ module.exports = {
it('Rendered correctly', function() { it('Rendered correctly', function() {
var prop = view.el; var prop = view.el;
$fixture.get(0).querySelector('.property').should.be.ok; expect($fixture.get(0).querySelector('.property')).toExist();
prop.querySelector('.label').should.be.ok; expect(prop.querySelector('.label')).toExist();
prop.querySelector('.field').should.be.ok; expect(prop.querySelector('.field')).toExist();
}); });
it('Input should exist', function() { it('Input should exist', function() {
view.$input.should.be.ok; expect(view.$input).toExist();
}); });
it('Input value is empty', function() { it('Input value is empty', function() {
view.model.get('value').should.be.empty; expect(view.model.get('value')).toNotExist();
view.$input.val().should.be.empty; expect(view.$input.val()).toNotExist();
}); });
it('Model not change without update trigger', function() { it('Model not change without update trigger', function() {
view.$input.val(propValue); view.$input.val(propValue);
view.model.get('value').should.be.empty; expect(view.model.get('value')).toNotExist();
}); });
// Tests valueUpdated() // Tests valueUpdated()
it('Update model on input change', function() { it('Update model on input change', function() {
view.$input.val(propValue).trigger('change'); view.$input.val(propValue).trigger('change');
view.model.get('value').should.equal(propValue); expect(view.model.get('value')).toEqual(propValue);
}); });
// Tests getValueForTarget() // Tests getValueForTarget()
it('Get value for target', function() { it('Get value for target', function() {
view.model.set('value', propValue); view.model.set('value', propValue);
view.getValueForTarget().should.equal(propValue); expect(view.getValueForTarget()).toEqual(propValue);
}); });
// Tests valueChanged() -> ... // Tests valueChanged() -> ...
it('Update input on value change', function() { it('Update input on value change', function() {
view.model.set('value', propValue); view.model.set('value', propValue);
view.$input.val().should.equal(propValue); expect(view.$input.val()).toEqual(propValue);
}); });
it('Update target on value change', function() { it('Update target on value change', function() {
@ -87,7 +87,7 @@ module.exports = {
var compStyle = view.selectedComponent.get('style'); var compStyle = view.selectedComponent.get('style');
var assertStyle = {}; var assertStyle = {};
assertStyle[propName] = propValue; assertStyle[propName] = propValue;
compStyle.should.deep.equal(assertStyle); expect(compStyle).toEqual(assertStyle);
}); });
it('Update target on value change with functionName', function() { it('Update target on value change with functionName', function() {
@ -97,7 +97,7 @@ module.exports = {
var compStyle = view.selectedComponent.get('style'); var compStyle = view.selectedComponent.get('style');
var assertStyle = {}; var assertStyle = {};
assertStyle[propName] = 'testfunc(' + propValue + ')'; assertStyle[propName] = 'testfunc(' + propValue + ')';
compStyle.should.deep.equal(assertStyle); expect(compStyle).toEqual(assertStyle);
}); });
it('Clean target from the property if its value is empty', function() { it('Clean target from the property if its value is empty', function() {
@ -105,25 +105,25 @@ module.exports = {
view.model.set('value', propValue); view.model.set('value', propValue);
view.model.set('value', ''); view.model.set('value', '');
var compStyle = view.selectedComponent.get('style'); var compStyle = view.selectedComponent.get('style');
compStyle.should.deep.equal({}); expect(compStyle).toEqual({});
}); });
it('Check stylable element', function() { it('Check stylable element', function() {
view.selectedComponent = component; view.selectedComponent = component;
view.isTargetStylable().should.equal(true); expect(view.isTargetStylable()).toEqual(true);
component.set('stylable', false); component.set('stylable', false);
view.isTargetStylable().should.equal(false); expect(view.isTargetStylable()).toEqual(false);
component.set('stylable', [propName]); component.set('stylable', [propName]);
view.isTargetStylable().should.equal(true); expect(view.isTargetStylable()).toEqual(true);
component.set('stylable', ['test1', propName]); component.set('stylable', ['test1', propName]);
view.isTargetStylable().should.equal(true); expect(view.isTargetStylable()).toEqual(true);
component.set('stylable', ['test1', 'test2']); component.set('stylable', ['test1', 'test2']);
view.isTargetStylable().should.equal(false); expect(view.isTargetStylable()).toEqual(false);
}); });
it('Target style is empty without values', function() { it('Target style is empty without values', function() {
view.selectedComponent = component; view.selectedComponent = component;
view.getComponentValue().should.be.empty; expect(view.getComponentValue()).toNotExist();
}); });
it('Target style is correct', function() { it('Target style is correct', function() {
@ -131,7 +131,7 @@ module.exports = {
var style = {}; var style = {};
style[propName] = propValue; style[propName] = propValue;
component.set('style', style); component.set('style', style);
view.getComponentValue().should.equal(propValue); expect(view.getComponentValue()).toEqual(propValue);
}); });
it('Target style is empty with an other style', function() { it('Target style is empty with an other style', function() {
@ -139,7 +139,7 @@ module.exports = {
var style = {}; var style = {};
style[propName + '2'] = propValue; style[propName + '2'] = propValue;
component.set('style', style); component.set('style', style);
view.getComponentValue().should.be.empty; expect(view.getComponentValue()).toNotExist();
}); });
it('Fetch value from function', function() { it('Fetch value from function', function() {
@ -148,7 +148,7 @@ module.exports = {
style[propName] = 'testfun(' + propValue + ')'; style[propName] = 'testfun(' + propValue + ')';
component.set('style', style); component.set('style', style);
view.model.set('functionName', 'testfun'); view.model.set('functionName', 'testfun');
view.getComponentValue().should.equal(propValue); expect(view.getComponentValue()).toEqual(propValue);
}); });
describe('With target setted', function() { describe('With target setted', function() {
@ -167,14 +167,14 @@ module.exports = {
view.updateTargetStyle(propValue); view.updateTargetStyle(propValue);
var style = {}; var style = {};
style[propName] = propValue; style[propName] = propValue;
component.get('style').should.deep.equal(style); expect(component.get('style')).toEqual(style);
}); });
it('updateTargetStyle with custom property', function() { it('updateTargetStyle with custom property', function() {
view.updateTargetStyle(propValue, propName + '2'); view.updateTargetStyle(propValue, propName + '2');
var style = {}; var style = {};
style[propName + '2'] = propValue; style[propName + '2'] = propValue;
component.get('style').should.deep.equal(style); expect(component.get('style')).toEqual(style);
}); });
it('Update value and input on target swap', function() { it('Update value and input on target swap', function() {
@ -182,8 +182,8 @@ module.exports = {
style[propName] = propValue; style[propName] = propValue;
component.set('style', style); component.set('style', style);
view.propTarget.trigger('update'); view.propTarget.trigger('update');
view.model.get('value').should.equal(propValue); expect(view.model.get('value')).toEqual(propValue);
view.$input.val().should.equal(propValue); expect(view.$input.val()).toEqual(propValue);
}); });
it('Update value after multiple swaps', function() { it('Update value after multiple swaps', function() {
@ -194,8 +194,8 @@ module.exports = {
style[propName] = propValue + '2'; style[propName] = propValue + '2';
component.set('style', style); component.set('style', style);
view.propTarget.trigger('update'); view.propTarget.trigger('update');
view.model.get('value').should.equal(propValue + '2'); expect(view.model.get('value')).toEqual(propValue + '2');
view.$input.val().should.equal(propValue + '2'); expect(view.$input.val()).toEqual(propValue + '2');
}); });
}) })
@ -216,15 +216,15 @@ module.exports = {
}); });
it('Value as default', function() { it('Value as default', function() {
view.model.get('value').should.equal(defValue); expect(view.model.get('value')).toEqual(defValue);
}); });
it('Placeholder as default', function() { it('Placeholder as default', function() {
view.$input.attr('placeholder').should.equal(defValue); expect(view.$input.attr('placeholder')).toEqual(defValue);
}); });
it('Input value is empty', function() { it('Input value is empty', function() {
view.$input.val().should.equal(defValue); expect(view.$input.val()).toEqual(defValue);
}); });
}); });

Loading…
Cancel
Save