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();
SectorView.run();
SectorsView.run();
/*
PropertyView.run();
/*
PropertySelectView.run();
PropertyRadioView.run();
PropertyIntegerView.run();

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

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

Loading…
Cancel
Save