Browse Source

Fix ButtonView tests

pull/1446/head
Artur Arseniev 8 years ago
parent
commit
1c76491220
  1. 7
      src/panels/view/ButtonView.js
  2. 5
      test/specs/panels/view/ButtonView.js

7
src/panels/view/ButtonView.js

@ -41,7 +41,9 @@ module.exports = Backbone.View.extend({
updateClassName() {
const { model, pfx } = this;
const cls = model.get('className');
this.$el.attr('class', `${pfx}btn ${cls ? cls : ''}`.trim());
const attrCls = model.get('attributes').class;
const classStr = `${attrCls ? attrCls : ''} ${pfx}btn ${cls ? cls : ''}`;
this.$el.attr('class', classStr.trim());
},
/**
@ -51,6 +53,7 @@ module.exports = Backbone.View.extend({
* */
updateAttributes() {
this.$el.attr(this.model.get('attributes'));
this.updateClassName();
},
/**
@ -154,11 +157,9 @@ module.exports = Backbone.View.extend({
const { $el } = this;
$el.empty();
this.updateAttributes();
$el.attr('class', this.className);
label && $el.append(label);
this.checkActive();
this.updateDisable();
this.updateClassName();
return this;
}

5
test/specs/panels/view/ButtonView.js

@ -3,7 +3,7 @@ const Button = require('panels/model/Button');
module.exports = {
run() {
describe.only('ButtonView', () => {
describe('ButtonView', () => {
var fixtures;
var model;
var view;
@ -58,13 +58,12 @@ module.exports = {
test('Disable the button', () => {
model.set('disable', true, { silent: true });
view.updateDisable();
expect(view.el.getAttribute('class')).toEqual(btnClass + ' active');
expect(view.el.getAttribute('class')).toEqual(btnClass + ' disabled');
});
test('Enable the disabled button', () => {
model.set('disable', true, { silent: true });
view.updateDisable();
expect(view.el.getAttribute('class')).toEqual(btnClass + ' active');
model.set('disable', false, { silent: true });
view.updateDisable();
expect(view.el.getAttribute('class')).toEqual(btnClass);

Loading…
Cancel
Save