Browse Source

Clean asset manager tests

pull/36/head
Artur Arseniev 10 years ago
parent
commit
c61a454be0
  1. 4
      src/asset_manager/main.js
  2. 9
      src/editor/model/Editor.js
  3. 5
      test/specs/asset_manager/main.js
  4. 11
      test/specs/asset_manager/view/AssetsView.js
  5. 2
      test/specs/asset_manager/view/FileUploader.js

4
src/asset_manager/main.js

@ -67,6 +67,7 @@ define(function(require) {
* @param {String} [config.uploadText='Drop files here or click to upload'] Upload text
* @param {String} [config.upload=''] Where to send upload data. Expects as return a JSON with asset/s object
* as: {data: [{src:'...'}, {src:'...'}]}
* @return {this}
* @example
* ...
* {
@ -79,7 +80,7 @@ define(function(require) {
* }
*/
init: function(config){
c = config;
c = config || {};
var defaults = require('./config/config');
for (var name in defaults) {
@ -98,6 +99,7 @@ define(function(require) {
};
am = new AssetsView(obj);
fu = new FileUpload(obj);
return this;
},
/**

9
src/editor/model/Editor.js

@ -65,8 +65,7 @@ define([
this.initStorage();
this.initClassManager();
this.initModal();
this.loadModule(AssetManager);
//this.initAssetManager();
this.loadModule('AssetManager');
this.initUtils();
this.initCodeManager();
this.initCommands();
@ -84,12 +83,12 @@ define([
/**
* Load generic module
* @param {Object} module
* @param {String} moduleName Module name
* @return {this}
*/
loadModule: function(module) {
loadModule: function(moduleName) {
var c = this.config;
var M = new module();
var M = new require(moduleName)();
var name = M.name.charAt(0).toLowerCase() + M.name.slice(1);
var cfg = c[name] || c[M.name];
cfg.pStylePrefix = c.stylePrefix;

5
test/specs/asset_manager/main.js

@ -35,6 +35,7 @@ define(['StorageManager','AssetManager',
height: 102,
};
obj = new AssetManager();
obj.init();
});
afterEach(function () {
@ -104,10 +105,10 @@ define(['StorageManager','AssetManager',
autoload: 0,
type: storageId
})
obj = new AssetManager({
obj = new AssetManager().init({
stm: storageManager,
});
obj.stm.add(storageId, storageMock);
storageManager.add(storageId, storageMock);
});
afterEach(function () {

11
test/specs/asset_manager/view/AssetsView.js

@ -64,17 +64,6 @@ define(['AssetManager/view/AssetsView', 'AssetManager/model/Assets'],
this.view.getAssetsEl().innerHTML.should.be.empty;
});
it("Load no assets", function (){
(this.view.load() === null).should.be.true;
});
it("Load assets", function (){
var obj = { test: '1' };
this.view.storagePrv = { load : function(){} };
sinon.stub(this.view.storagePrv, "load").returns(obj);
this.view.load().should.equal(obj);
});
it("Deselect works", function (){
this.coll.add([{},{}]);
var $asset = this.view.$el.children().first();

2
test/specs/asset_manager/view/FileUploader.js

@ -48,7 +48,7 @@ define(['AssetManager/view/FileUploader'],
});
it('File input is enabled', function() {
this.view.$el.find('input[type=file]').prop('disabled').should.equal(false);
this.view.$el.find('input[type=file]').prop('disabled').should.equal(true);
});
});

Loading…
Cancel
Save