Browse Source

Update integer property view tests

no-jquery
Artur Arseniev 9 years ago
parent
commit
5d4976b8b2
  1. 4
      src/style_manager/view/PropertyIntegerView.js
  2. 30
      test/specs/style_manager/view/PropertyIntegerView.js

4
src/style_manager/view/PropertyIntegerView.js

@ -1,4 +1,5 @@
const InputNumber = require('domain_abstract/ui/InputNumber');
const $ = Backbone.$;
module.exports = require('./PropertyView').extend({
@ -28,7 +29,8 @@ module.exports = require('./PropertyView').extend({
const fields = this.el.querySelector(`.${ppfx}fields`);
fields.appendChild(input.el);
this.$input = input.inputEl;
this.$unit = input.unitEl;
this.unit = input.unitEl;
this.$unit = $(this.unit);
this.input = this.$input.get(0);
this.inputInst = input;
}

30
test/specs/style_manager/view/PropertyIntegerView.js

@ -8,8 +8,7 @@ module.exports = {
describe('PropertyIntegerView', () => {
var component;
var $fixtures;
var $fixture;
var fixtures;
var target;
var model;
var view;
@ -24,11 +23,6 @@ module.exports = {
var maxValue = 75;
var unitsElSel = '.field-units select';
before(() => {
$fixtures = $("#fixtures");
$fixture = $('<div class="sm-fixture"></div>');
});
beforeEach(() => {
target = new Component();
component = new Component();
@ -43,9 +37,10 @@ module.exports = {
model,
propTarget
});
$fixture.empty().appendTo($fixtures);
document.body.innerHTML = '<div id="fixtures"></div>';
fixtures = document.body.firstChild;
view.render();
$fixture.html(view.el);
fixtures.appendChild(view.el);
});
afterEach(() => {
@ -53,7 +48,6 @@ module.exports = {
});
after(() => {
$fixture.remove();
component = null;
view = null;
model = null;
@ -61,7 +55,7 @@ module.exports = {
it('Rendered correctly', () => {
var prop = view.el;
expect($fixture.get(0).querySelector('.property')).toExist();
expect(fixtures.querySelector('.property')).toExist();
expect(prop.querySelector('.label')).toExist();
expect(prop.querySelector('.field')).toExist();
});
@ -85,8 +79,8 @@ module.exports = {
});
it('Inputs should exist', () => {
expect(view.$input).toExist();
expect(view.$unit).toExist();
expect(view.input).toExist();
expect(view.unit).toExist();
});
it('Input value is empty', () => {
@ -98,7 +92,7 @@ module.exports = {
expect(view.model.get('value')).toEqual(parseFloat(intValue));
expect(view.model.get('unit')).toEqual(unitValue);
expect(view.getInputValue()).toEqual(intValue);
expect(view.$unit.val()).toEqual(unitValue);
expect(view.unit.value).toEqual(unitValue);
});
it('Update model on input change', () => {
@ -133,9 +127,9 @@ module.exports = {
model,
propTarget: target
});
$fixture.empty().appendTo($fixtures);
fixtures.innerHTML = '';
view.render();
$fixture.html(view.el);
fixtures.appendChild(view.el);
});
it('Update value and input on target swap', () => {
@ -179,9 +173,9 @@ module.exports = {
view = new PropertyIntegerView({
model
});
$fixture.empty().appendTo($fixtures);
fixtures.innerHTML = '';
view.render();
$fixture.html(view.el);
fixtures.appendChild(view.el);
});
it('Value as default', () => {

Loading…
Cancel
Save