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

9
src/editor/model/Editor.js

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

5
test/specs/asset_manager/main.js

@ -35,6 +35,7 @@ define(['StorageManager','AssetManager',
height: 102, height: 102,
}; };
obj = new AssetManager(); obj = new AssetManager();
obj.init();
}); });
afterEach(function () { afterEach(function () {
@ -104,10 +105,10 @@ define(['StorageManager','AssetManager',
autoload: 0, autoload: 0,
type: storageId type: storageId
}) })
obj = new AssetManager({ obj = new AssetManager().init({
stm: storageManager, stm: storageManager,
}); });
obj.stm.add(storageId, storageMock); storageManager.add(storageId, storageMock);
}); });
afterEach(function () { 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; 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 (){ it("Deselect works", function (){
this.coll.add([{},{}]); this.coll.add([{},{}]);
var $asset = this.view.$el.children().first(); 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() { 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