diff --git a/test/runner/main.js b/test/runner/main.js index 4574136a0..289a0d01a 100644 --- a/test/runner/main.js +++ b/test/runner/main.js @@ -1,6 +1,7 @@ require(['../src/config/require-config.js', 'config/config.js'], function() { require(['chai', + 'sinon', 'specs/main.js', 'specs/asset_manager/main.js', 'specs/asset_manager/model/Asset.js', diff --git a/test/specs/asset_manager/main.js b/test/specs/asset_manager/main.js index 0ccc64d5f..ce1b39c6c 100644 --- a/test/specs/asset_manager/main.js +++ b/test/specs/asset_manager/main.js @@ -1,17 +1,57 @@ define(['AssetManager'], function(AssetManager) { - + describe('Asset Manager', function() { - + describe('Main', function() { it('Object exists', function() { AssetManager.should.be.exist; }); - + it('No assets inside', function() { var obj = new AssetManager(); obj.getAssets().length.should.be.empty; }); + + it('AssetsView exists and is an instance of Backbone.View', function() { + var obj = new AssetManager(); + obj.am.should.be.exist; + obj.am.should.be.an.instanceOf(Backbone.View); + }); + + it('FileUpload exists and is an instance of Backbone.View', function() { + var obj = new AssetManager(); + obj.fu.should.be.exist; + obj.fu.should.be.an.instanceOf(Backbone.View); + }); + + it('Target is assigning', function() { + var obj = new AssetManager(); + var t = 'target'; + obj.setTarget(t); + obj.am.collection.target.should.equal(t); + }); + + it('onSelect callback is assigning', function() { + var obj = new AssetManager(); + var cb = function(){ + return 'callback'; + }; + obj.onSelect(cb); + obj.am.collection.onSelect.should.equal(cb); + }); + + it('Render propagates', function() { + var obj = new AssetManager(), + jq = { $el: $('
') }; + sinon.stub(obj.am, "render").returns(jq); + sinon.stub(obj.fu, "render").returns(jq); + obj.render(); + obj.am.render.calledOnce.should.equal(true); + obj.fu.render.calledOnce.should.equal(true); + obj.rendered.should.not.be.empty; + }); + }); }); }); \ No newline at end of file