Browse Source

More Commands tests

pull/36/head
Artur Arseniev 11 years ago
parent
commit
707dbd1307
  1. 15
      src/commands/view/CommandAbstract.js
  2. 28
      test/specs/commands/main.js
  3. 44
      test/specs/commands/model/CommandModels.js

15
src/commands/view/CommandAbstract.js

@ -12,18 +12,19 @@ define(['backbone'],
* @private * @private
* */ * */
initialize: function(o) { initialize: function(o) {
this.config = o; this.config = o || {};
this.editorModel = this.em = o.em || {}; this.editorModel = this.em = this.config.em || {};
this.canvasId = o.canvasId || ''; this.canvasId = this.config.canvasId || '';
this.wrapperId = o.wrapperId || 'wrapper'; this.wrapperId = this.config.wrapperId || 'wrapper';
this.pfx = o.stylePrefix; this.pfx = this.config.stylePrefix;
this.hoverClass = this.pfx + 'hover'; this.hoverClass = this.pfx + 'hover';
this.badgeClass = this.pfx + 'badge'; this.badgeClass = this.pfx + 'badge';
this.plhClass = this.pfx + 'placeholder'; this.plhClass = this.pfx + 'placeholder';
this.setElement(this.editorModel.get('$editor').find('#'+this.canvasId)); if(this.editorModel.get)
this.setElement(this.editorModel.get('$editor').find('#'+this.canvasId));
this.$canvas = this.$el; this.$canvas = this.$el;
this.$wrapper = this.$canvas.find('#'+this.wrapperId); this.$wrapper = this.$canvas.find('#'+this.wrapperId);
this.init(o); this.init(this.config);
}, },
/** /**

28
test/specs/commands/main.js

@ -1,9 +1,12 @@
var modulePath = './../../../test/specs/commands'; var modulePath = './../../../test/specs/commands';
define([ define([
'Commands'], 'Commands',
modulePath + '/model/CommandModels',
],
function( function(
Commands Commands,
Models
) { ) {
describe('Commands', function() { describe('Commands', function() {
@ -20,11 +23,28 @@ define([
delete obj; delete obj;
}); });
it('Object exists', function() { it('No commands inside', function() {
obj.should.be.exist; (obj.get('test') == null).should.equal(true);
});
it('Push new command', function() {
var comm = { test: 'test'};
obj.add('test', comm);
(obj.get('test').test == 'test').should.equal(true);
});
it('No default commands at init', function() {
(obj.get('select-comp') == null).should.equal(true);
});
it('Default commands after loadDefaultCommands', function() {
obj.loadDefaultCommands();
(obj.get('select-comp') == null).should.equal(false);
}); });
}); });
}); });
Models.run();
}); });

44
test/specs/commands/model/CommandModels.js

@ -0,0 +1,44 @@
var path = 'Commands/model/';
define([path + 'Command', path + 'Commands'],
function(Command, Commands) {
return {
run : function(){
describe('Command', function() {
var obj;
beforeEach(function () {
obj = new Command();
});
afterEach(function () {
delete obj;
});
it('Has id property', function() {
obj.has('id').should.equal(true);
});
});
describe('Commands', function() {
var obj;
beforeEach(function () {
obj = new Commands();
});
afterEach(function () {
delete obj;
});
it('Object is ok', function() {
obj.should.be.ok;
});
});
}
};
});
Loading…
Cancel
Save