diff --git a/src/asset_manager/template/assetImage.html b/src/asset_manager/template/assetImage.html
deleted file mode 100644
index 67d533051..000000000
--- a/src/asset_manager/template/assetImage.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-⨯
-
\ No newline at end of file
diff --git a/src/asset_manager/template/assets.html b/src/asset_manager/template/assets.html
deleted file mode 100644
index 755c899fb..000000000
--- a/src/asset_manager/template/assets.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
diff --git a/src/asset_manager/template/fileUploader.html b/src/asset_manager/template/fileUploader.html
deleted file mode 100644
index 8f8a07751..000000000
--- a/src/asset_manager/template/fileUploader.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
\ No newline at end of file
diff --git a/src/asset_manager/view/AssetImageView.js b/src/asset_manager/view/AssetImageView.js
index d5d32b794..52418b4e5 100644
--- a/src/asset_manager/view/AssetImageView.js
+++ b/src/asset_manager/view/AssetImageView.js
@@ -1,5 +1,16 @@
var AssetView = require('./AssetView');
-var assetTemplate = require('text!./../template/assetImage.html');
+var assetTemplate = `
+
+
+⨯
+
+`;
module.exports = AssetView.extend({
diff --git a/src/asset_manager/view/AssetsView.js b/src/asset_manager/view/AssetsView.js
index 16ce777f6..6d8f38614 100644
--- a/src/asset_manager/view/AssetsView.js
+++ b/src/asset_manager/view/AssetsView.js
@@ -2,7 +2,26 @@ var Backbone = require('backbone');
var AssetView = require('./AssetView');
var AssetImageView = require('./AssetImageView');
var FileUploader = require('./FileUploader');
-var assetsTemplate = require('text!./../template/assets.html');
+var assetsTemplate = `
+
+
+`;
module.exports = Backbone.View.extend({
diff --git a/src/asset_manager/view/FileUploader.js b/src/asset_manager/view/FileUploader.js
index c137c8ebe..908bfa5f5 100644
--- a/src/asset_manager/view/FileUploader.js
+++ b/src/asset_manager/view/FileUploader.js
@@ -1,5 +1,11 @@
var Backbone = require('backbone');
-var fileUploaderTemplate = require('text!./../template/fileUploader.html');
+var fileUploaderTemplate = `
+
+`;
module.exports = Backbone.View.extend({
diff --git a/src/utils/Resizer.js b/src/utils/Resizer.js
index c0ef043d3..2893033d1 100644
--- a/src/utils/Resizer.js
+++ b/src/utils/Resizer.js
@@ -21,7 +21,7 @@ var defaults = {
var createHandler = function (name, opts) {
var pfx = opts.prefix || '';
- var el = this.document.createElement('i');
+ var el = document.createElement('i');
el.className = pfx + 'resizer-h ' + pfx + 'resizer-h-' + name;
el.setAttribute('data-' + pfx + 'handler', name);
return el;
diff --git a/test/helper.js b/test/helper.js
index e99cbc0f4..e4f3c2f12 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -1,8 +1,10 @@
+import _ from 'underscore';
import { JSDOM } from 'jsdom';
const dom = new JSDOM('');
global.window = dom.window;
global.document = dom.window.document;
+global._ = _;
Object.keys(window).forEach((key) => {
if (!(key in global)) {
diff --git a/test/main.js b/test/main.js
index 3b947b030..d4284cdc6 100644
--- a/test/main.js
+++ b/test/main.js
@@ -1,13 +1,17 @@
import expect from 'expect';
import sinon from 'sinon';
-//import grapesjs from './../src/main.js';
-//const grapesjs = require('./../src/main.js');
+import grapesjs from './../src';
+//import AssetManager from './specs/asset_manager';
-describe('Main', function() {
- describe('Startup', function() {
- it('Main object should be loaded', function() {
- var grru = require('./../src');
+describe('Main', () => {
+
+ describe('Startup', () => {
+ it('Main object should be loaded', () => {
//Grapes = require('editor/main');
+ expect(grapesjs).toExist();
});
});
+
+ require('./specs/asset_manager/main.js');
+
});
diff --git a/test/specs/asset_manager/main.js b/test/specs/asset_manager/main.js
index fb487b02d..06f0acba3 100644
--- a/test/specs/asset_manager/main.js
+++ b/test/specs/asset_manager/main.js
@@ -1,136 +1,133 @@
-define(function(require, exports, module){
- 'use strict';
- var StorageManager = require('StorageManager');
- var AssetManager = require('AssetManager');
- var FileUploader = require('undefined');
-
- describe('Asset Manager', function() {
-
- describe('Main', function() {
-
- var obj;
- var imgObj;
-
- var storage;
- var storageId = 'testStorage';
- var storageMock = {
- store: function(data){
- storage = data;
- },
- load: function(keys){
- return storage;
- },
- };
-
- beforeEach(function () {
- imgObj = {
- src: 'path/to/image',
- width: 101,
- height: 102,
- };
- obj = new AssetManager();
- obj.init();
+var StorageManager = require('storage_manager');
+var AssetManager = require('asset_manager');
+var FileUploader = require('./view/FileUploader');
+
+describe('Asset Manager', function() {
+
+ describe('Main', function() {
+
+ var obj;
+ var imgObj;
+
+ var storage;
+ var storageId = 'testStorage';
+ var storageMock = {
+ store: function(data){
+ storage = data;
+ },
+ load: function(keys){
+ return storage;
+ },
+ };
+
+ beforeEach(function () {
+ imgObj = {
+ src: 'path/to/image',
+ width: 101,
+ height: 102,
+ };
+ obj = new AssetManager();
+ obj.init();
+ });
+
+ afterEach(function () {
+ obj = null;
+ });
+
+ it('Object exists', function() {
+ obj.should.be.exist;
+ });
+
+ it('No assets inside', function() {
+ obj.getAll().length.should.be.empty;
+ });
+
+ it('Add new asset', function() {
+ obj.add(imgObj);
+ obj.getAll().length.should.equal(1);
+ });
+
+ it('Added asset has correct data', function() {
+ obj.add(imgObj);
+ var asset = obj.get(imgObj.src);
+ asset.get('width').should.equal(imgObj.width);
+ asset.get('height').should.equal(imgObj.height);
+ asset.get('type').should.equal('image');
+ });
+
+ it('Add asset with src', function() {
+ obj.add(imgObj.src);
+ var asset = obj.get(imgObj.src);
+ asset.get('type').should.equal('image');
+ asset.get('src').should.equal(imgObj.src);
+ });
+
+ it('Add asset with more src', function() {
+ obj.add([imgObj.src, imgObj.src + '2']);
+ obj.getAll().length.should.equal(2);
+ var asset1 = obj.getAll().at(0);
+ var asset2 = obj.getAll().at(1);
+ asset1.get('src').should.equal(imgObj.src);
+ asset2.get('src').should.equal(imgObj.src + '2');
+ });
+
+ it('Src is unique', function() {
+ obj.add(imgObj);
+ obj.add(imgObj);
+ obj.getAll().length.should.equal(1);
+ });
+
+ it('Remove asset', function() {
+ obj.add(imgObj);
+ obj.remove(imgObj.src);
+ obj.getAll().length.should.equal(0);
+ });
+
+ it('Render assets', function() {
+ obj.add(imgObj);
+ obj.render().should.not.be.empty;
+ });
+
+ describe('With storage', function() {
+
+ var storageManager;
+
+ beforeEach(function () {
+ storageManager = new StorageManager().init({
+ autoload: 0,
+ type: storageId
+ })
+ obj = new AssetManager().init({
+ stm: storageManager,
});
-
- afterEach(function () {
- delete obj;
- });
-
- it('Object exists', function() {
- obj.should.be.exist;
- });
-
- it('No assets inside', function() {
- obj.getAll().length.should.be.empty;
- });
-
- it('Add new asset', function() {
- obj.add(imgObj);
- obj.getAll().length.should.equal(1);
- });
-
- it('Added asset has correct data', function() {
- obj.add(imgObj);
- var asset = obj.get(imgObj.src);
- asset.get('width').should.equal(imgObj.width);
- asset.get('height').should.equal(imgObj.height);
- asset.get('type').should.equal('image');
- });
-
- it('Add asset with src', function() {
- obj.add(imgObj.src);
- var asset = obj.get(imgObj.src);
- asset.get('type').should.equal('image');
- asset.get('src').should.equal(imgObj.src);
- });
-
- it('Add asset with more src', function() {
- obj.add([imgObj.src, imgObj.src + '2']);
- obj.getAll().length.should.equal(2);
- var asset1 = obj.getAll().at(0);
- var asset2 = obj.getAll().at(1);
- asset1.get('src').should.equal(imgObj.src);
- asset2.get('src').should.equal(imgObj.src + '2');
- });
-
- it('Src is unique', function() {
- obj.add(imgObj);
- obj.add(imgObj);
- obj.getAll().length.should.equal(1);
- });
-
- it('Remove asset', function() {
- obj.add(imgObj);
- obj.remove(imgObj.src);
- obj.getAll().length.should.equal(0);
- });
-
- it('Render assets', function() {
- obj.add(imgObj);
- obj.render().should.not.be.empty;
- });
-
- describe('With storage', function() {
-
- var storageManager;
-
- beforeEach(function () {
- storageManager = new StorageManager().init({
- autoload: 0,
- type: storageId
- })
- obj = new AssetManager().init({
- stm: storageManager,
- });
- storageManager.add(storageId, storageMock);
- });
-
- afterEach(function () {
- delete storageManager;
- });
-
- it('Store and load data', function() {
- obj.add(imgObj);
- obj.store();
- obj.remove(imgObj.src);
- obj.load();
- var asset = obj.get(imgObj.src);
- asset.get('width').should.equal(imgObj.width);
- asset.get('height').should.equal(imgObj.height);
- asset.get('type').should.equal('image');
- });
-
- });
-
- });
-
- Asset.run();
- AssetImage.run();
- Assets.run();
-
- AssetView.run();
- AssetImageView.run();
- AssetsView.run();
- FileUploader.run();
- });
+ storageManager.add(storageId, storageMock);
+ });
+
+ afterEach(function () {
+ storageManager = null;
+ });
+
+ it('Store and load data', function() {
+ obj.add(imgObj);
+ obj.store();
+ obj.remove(imgObj.src);
+ obj.load();
+ var asset = obj.get(imgObj.src);
+ asset.get('width').should.equal(imgObj.width);
+ asset.get('height').should.equal(imgObj.height);
+ asset.get('type').should.equal('image');
+ });
+
+ });
+
+ });
+
+ require('./model/Asset').run();
+ require('./model/AssetImage').run();
+ require('./model/Assets').run();
+
+ require('./view/AssetView').run();
+ require('./view/AssetImageView').run();
+ require('./view/AssetsView').run();
+ require('./view/FileUploader').run();
});
diff --git a/test/specs/asset_manager/model/Asset.js b/test/specs/asset_manager/model/Asset.js
index 9613ae230..7a904ccf8 100644
--- a/test/specs/asset_manager/model/Asset.js
+++ b/test/specs/asset_manager/model/Asset.js
@@ -1,37 +1,34 @@
-define(function(require, exports, module){
- 'use strict';
- var Asset = require('AssetManager/model/Asset');
+var Asset = require('asset_manager/model/Asset');
- module.exports = {
- run: function(){
+module.exports = {
+ run: function(){
- describe('Asset', function() {
- it('Object exists', function() {
- Asset.should.be.exist;
- });
+ describe('Asset', function() {
+ it('Object exists', function() {
+ Asset.should.be.exist;
+ });
- it('Has default values', function() {
- var obj = new Asset({});
- obj.get('type').should.equal("");
- obj.get('src').should.equal("");
- obj.getExtension().should.be.empty;
- obj.getFilename().should.be.empty;
- });
+ it('Has default values', function() {
+ var obj = new Asset({});
+ obj.get('type').should.equal("");
+ obj.get('src').should.equal("");
+ obj.getExtension().should.be.empty;
+ obj.getFilename().should.be.empty;
+ });
- it('Test getFilename', function() {
- var obj = new Asset({ type:'image', src: 'ch/eck/t.e.s.t'});
- obj.getFilename().should.equal('t.e.s.t');
- var obj = new Asset({ type:'image', src: 'ch/eck/1234abc'});
- obj.getFilename().should.equal('1234abc');
- });
+ it('Test getFilename', function() {
+ var obj = new Asset({ type:'image', src: 'ch/eck/t.e.s.t'});
+ obj.getFilename().should.equal('t.e.s.t');
+ var obj = new Asset({ type:'image', src: 'ch/eck/1234abc'});
+ obj.getFilename().should.equal('1234abc');
+ });
- it('Test getExtension', function() {
- var obj = new Asset({ type:'image', src: 'ch/eck/t.e.s.t'});
- obj.getExtension().should.equal('t');
- var obj = new Asset({ type:'image', src: 'ch/eck/1234abc.'});
- obj.getExtension().should.equal('');
- });
- });
- }
- }
-});
\ No newline at end of file
+ it('Test getExtension', function() {
+ var obj = new Asset({ type:'image', src: 'ch/eck/t.e.s.t'});
+ obj.getExtension().should.equal('t');
+ var obj = new Asset({ type:'image', src: 'ch/eck/1234abc.'});
+ obj.getExtension().should.equal('');
+ });
+ });
+ }
+}
diff --git a/test/specs/asset_manager/model/AssetImage.js b/test/specs/asset_manager/model/AssetImage.js
index b1918fcc7..c3f92d7d5 100644
--- a/test/specs/asset_manager/model/AssetImage.js
+++ b/test/specs/asset_manager/model/AssetImage.js
@@ -1,28 +1,25 @@
-define(function(require, exports, module){
- 'use strict';
- var AssetImage = require('AssetManager/model/AssetImage');
+var AssetImage = require('asset_manager/model/AssetImage');
- module.exports = {
- run: function() {
+module.exports = {
+ run: function() {
- describe('AssetImage', function() {
- it('Object exists', function() {
- AssetImage.should.be.exist;
- });
+ describe('AssetImage', function() {
+ it('Object exists', function() {
+ AssetImage.should.be.exist;
+ });
- it('Has default values', function() {
- var obj = new AssetImage({});
- obj.get('type').should.equal("image");
- obj.get('src').should.equal("");
- obj.get('unitDim').should.equal("px");
- obj.get('height').should.equal(0);
- obj.get('width').should.equal(0);
- obj.getExtension().should.be.empty;
- obj.getFilename().should.be.empty;
- });
+ it('Has default values', function() {
+ var obj = new AssetImage({});
+ obj.get('type').should.equal("image");
+ obj.get('src').should.equal("");
+ obj.get('unitDim').should.equal("px");
+ obj.get('height').should.equal(0);
+ obj.get('width').should.equal(0);
+ obj.getExtension().should.be.empty;
+ obj.getFilename().should.be.empty;
+ });
- });
+ });
- }
- };
-});
\ No newline at end of file
+ }
+};
diff --git a/test/specs/asset_manager/model/Assets.js b/test/specs/asset_manager/model/Assets.js
index 090873363..8e216f729 100644
--- a/test/specs/asset_manager/model/Assets.js
+++ b/test/specs/asset_manager/model/Assets.js
@@ -1,54 +1,51 @@
-define(function(require, exports, module){
- 'use strict';
- var Assets = require('AssetManager/model/Assets');
-
- module.exports = {
- run: function() {
- describe('Assets', function() {
-
- var obj;
-
- beforeEach(function () {
- obj = new Assets();
- });
-
- afterEach(function () {
- delete obj;
- });
-
- it('Object exists', function() {
- obj.should.be.exist;
- });
-
- it('Collection is empty', function() {
- obj.length.should.equal(0);
- });
-
- it("Can't insert assets without src", function() {
- obj.add({});
- obj.length.should.equal(0);
- obj.add([{},{},{}]);
- obj.length.should.equal(0);
- });
-
- it("Insert assets only with src", function() {
- obj.add([{},{src:'test'},{}]);
- obj.length.should.equal(1);
- });
-
- it('addImg creates new asset', function() {
- obj.addImg('/img/path');
- obj.length.should.equal(1);
- });
-
- it('addImg asset is correct', function() {
- obj.addImg('/img/path');
- var asset = obj.at(0);
- asset.get('type').should.equal('image');
- asset.get('src').should.equal('/img/path');
- });
-
- });
- }
- };
-});
\ No newline at end of file
+var Assets = require('asset_manager/model/Assets');
+
+module.exports = {
+ run: function() {
+ describe('Assets', function() {
+
+ var obj;
+
+ beforeEach(function () {
+ obj = new Assets();
+ });
+
+ afterEach(function () {
+ obj = null;
+ });
+
+ it('Object exists', function() {
+ obj.should.be.exist;
+ });
+
+ it('Collection is empty', function() {
+ obj.length.should.equal(0);
+ });
+
+ it("Can't insert assets without src", function() {
+ obj.add({});
+ obj.length.should.equal(0);
+ obj.add([{},{},{}]);
+ obj.length.should.equal(0);
+ });
+
+ it("Insert assets only with src", function() {
+ obj.add([{},{src:'test'},{}]);
+ obj.length.should.equal(1);
+ });
+
+ it('addImg creates new asset', function() {
+ obj.addImg('/img/path');
+ obj.length.should.equal(1);
+ });
+
+ it('addImg asset is correct', function() {
+ obj.addImg('/img/path');
+ var asset = obj.at(0);
+ asset.get('type').should.equal('image');
+ asset.get('src').should.equal('/img/path');
+ });
+
+ });
+ }
+};
diff --git a/test/specs/asset_manager/view/AssetImageView.js b/test/specs/asset_manager/view/AssetImageView.js
index fb1c1c5e2..6fdd6951d 100644
--- a/test/specs/asset_manager/view/AssetImageView.js
+++ b/test/specs/asset_manager/view/AssetImageView.js
@@ -1,83 +1,80 @@
-define(function(require, exports, module){
- 'use strict';
- var AssetImageView = require('AssetManager/view/AssetImageView');
- var AssetImage = require('AssetManager/model/AssetImage');
- var Assets = require('AssetManager/model/Assets');
-
- module.exports = {
- run: function() {
-
- describe('AssetImageView', function() {
-
- before(function () {
- this.$fixtures = $("#fixtures");
- this.$fixture = $('');
- });
-
- beforeEach(function () {
- var coll = new Assets();
- var model = coll.add({ type:'image', src: '/test' });
- this.view = new AssetImageView({
- config : {},
- model: model
- });
- this.$fixture.empty().appendTo(this.$fixtures);
- this.$fixture.html(this.view.render().el);
- });
-
- afterEach(function () {
- delete this.view;
- });
-
- after(function () {
- this.$fixture.remove();
- });
-
- it('Object exists', function() {
- AssetImageView.should.be.exist;
- });
-
- describe('Asset should be rendered correctly', function() {
-
- it('Has preview box', function() {
- var $asset = this.view.$el;
- $asset.find('#preview').should.have.property(0);
- });
-
- it('Has meta box', function() {
- var $asset = this.view.$el;
- $asset.find('#meta').should.have.property(0);
- });
-
- it('Has close button', function() {
- var $asset = this.view.$el;
- $asset.find('#close').should.have.property(0);
- });
-
- });
-
- it('Could be selected', function() {
- sinon.stub(this.view, 'updateTarget');
- this.view.$el.trigger('click');
- this.view.$el.attr('class').should.contain('highlight');
- this.view.updateTarget.calledOnce.should.equal(true);
- });
-
- it('Could be chosen', function() {
- sinon.stub(this.view, 'updateTarget');
- this.view.$el.trigger('dblclick');
- this.view.updateTarget.calledOnce.should.equal(true);
- });
-
- it('Could be removed', function() {
- var spy = sinon.spy();
- this.view.model.on("remove", spy);
- this.view.$el.find('#close').trigger('click');
- spy.called.should.equal(true);
- });
-
- });
-
- }
- };
-});
\ No newline at end of file
+var AssetImageView = require('asset_manager/view/AssetImageView');
+var AssetImage = require('asset_manager/model/AssetImage');
+var Assets = require('asset_manager/model/Assets');
+
+module.exports = {
+ run: function() {
+
+ describe('AssetImageView', function() {
+
+ before(function () {
+ this.$fixtures = $("#fixtures");
+ this.$fixture = $('');
+ });
+
+ beforeEach(function () {
+ var coll = new Assets();
+ var model = coll.add({ type:'image', src: '/test' });
+ this.view = new AssetImageView({
+ config : {},
+ model: model
+ });
+ this.$fixture.empty().appendTo(this.$fixtures);
+ this.$fixture.html(this.view.render().el);
+ });
+
+ afterEach(function () {
+ delete this.view;
+ });
+
+ after(function () {
+ this.$fixture.remove();
+ });
+
+ it('Object exists', function() {
+ AssetImageView.should.be.exist;
+ });
+
+ describe('Asset should be rendered correctly', function() {
+
+ it('Has preview box', function() {
+ var $asset = this.view.$el;
+ $asset.find('#preview').should.have.property(0);
+ });
+
+ it('Has meta box', function() {
+ var $asset = this.view.$el;
+ $asset.find('#meta').should.have.property(0);
+ });
+
+ it('Has close button', function() {
+ var $asset = this.view.$el;
+ $asset.find('#close').should.have.property(0);
+ });
+
+ });
+
+ it('Could be selected', function() {
+ sinon.stub(this.view, 'updateTarget');
+ this.view.$el.trigger('click');
+ this.view.$el.attr('class').should.contain('highlight');
+ this.view.updateTarget.calledOnce.should.equal(true);
+ });
+
+ it('Could be chosen', function() {
+ sinon.stub(this.view, 'updateTarget');
+ this.view.$el.trigger('dblclick');
+ this.view.updateTarget.calledOnce.should.equal(true);
+ });
+
+ it('Could be removed', function() {
+ var spy = sinon.spy();
+ this.view.model.on("remove", spy);
+ this.view.$el.find('#close').trigger('click');
+ spy.called.should.equal(true);
+ });
+
+ });
+
+ }
+};
diff --git a/test/specs/asset_manager/view/AssetView.js b/test/specs/asset_manager/view/AssetView.js
index 89dbe1cb8..c31dfa381 100644
--- a/test/specs/asset_manager/view/AssetView.js
+++ b/test/specs/asset_manager/view/AssetView.js
@@ -1,48 +1,45 @@
-define(function(require, exports, module){
- 'use strict';
- var AssetView = require('AssetManager/view/AssetView');
- var Asset = require('AssetManager/model/Asset');
- var Assets = require('AssetManager/model/Assets');
-
- module.exports = {
- run: function() {
-
- describe('AssetView', function() {
-
- before(function () {
- this.$fixtures = $("#fixtures");
- this.$fixture = $('');
- });
-
- beforeEach(function () {
- var coll = new Assets();
- var model = coll.add({src: 'test'});
- this.view = new AssetView({
- config : {},
- model: model
- });
- this.$fixture.empty().appendTo(this.$fixtures);
- this.$fixture.html(this.view.render().el);
- });
-
- afterEach(function () {
- this.view.remove();
- });
-
- after(function () {
- this.$fixture.remove();
- });
-
- it('Object exists', function() {
- AssetView.should.be.exist;
- });
-
- it('Has correct prefix', function() {
- this.view.pfx.should.equal('');
- });
-
- });
-
- }
- }
-});
\ No newline at end of file
+var AssetView = require('asset_manager/view/AssetView');
+var Asset = require('asset_manager/model/Asset');
+var Assets = require('asset_manager/model/Assets');
+
+module.exports = {
+ run: function() {
+
+ describe('AssetView', function() {
+
+ before(function () {
+ this.$fixtures = $("#fixtures");
+ this.$fixture = $('');
+ });
+
+ beforeEach(function () {
+ var coll = new Assets();
+ var model = coll.add({src: 'test'});
+ this.view = new AssetView({
+ config : {},
+ model: model
+ });
+ this.$fixture.empty().appendTo(this.$fixtures);
+ this.$fixture.html(this.view.render().el);
+ });
+
+ afterEach(function () {
+ this.view.remove();
+ });
+
+ after(function () {
+ this.$fixture.remove();
+ });
+
+ it('Object exists', function() {
+ AssetView.should.be.exist;
+ });
+
+ it('Has correct prefix', function() {
+ this.view.pfx.should.equal('');
+ });
+
+ });
+
+ }
+}
diff --git a/test/specs/asset_manager/view/AssetsView.js b/test/specs/asset_manager/view/AssetsView.js
index b7792bbb1..0c1e01d8f 100644
--- a/test/specs/asset_manager/view/AssetsView.js
+++ b/test/specs/asset_manager/view/AssetsView.js
@@ -1,98 +1,95 @@
-define(function(require, exports, module){
- 'use strict';
- var AssetsView = require('AssetManager/view/AssetsView');
- var Assets = require('AssetManager/model/Assets');
-
- module.exports = {
- run: function() {
-
- describe('AssetsView', function() {
-
- var obj;
-
- before(function () {
- this.$fixtures = $("#fixtures");
- this.$fixture = $('');
- });
-
- beforeEach(function () {
- this.coll = new Assets([]);
- this.view = new AssetsView({
- config : {},
- collection: this.coll
- });
- obj = this.view;
- this.$fixture.empty().appendTo(this.$fixtures);
- this.$fixture.html(this.view.render().el);
- });
-
- afterEach(function () {
- this.view.collection.reset();
- });
-
- after(function () {
- this.$fixture.remove();
- });
-
- it('Object exists', function() {
- AssetsView.should.be.exist;
- });
-
- it("Collection is empty", function (){
- this.view.getAssetsEl().innerHTML.should.be.empty;
- });
-
- it("Add new asset", function (){
- sinon.stub(this.view, "addAsset");
- this.coll.add({src: 'test'});
- this.view.addAsset.calledOnce.should.equal(true);
- });
-
- it("Render new asset", function (){
- this.coll.add({src: 'test'});
- this.view.getAssetsEl().innerHTML.should.not.be.empty;
- });
-
- it("Render correctly new image asset", function (){
- this.coll.add({ type: 'image', src: 'test'});
- var asset = this.view.getAssetsEl().firstChild;
- asset.tagName.should.equal('DIV');
- asset.innerHTML.should.not.be.empty;
- });
-
- it("Clean collection from asset", function (){
- var model = this.coll.add({src: 'test'});
- this.coll.remove(model);
- this.view.getAssetsEl().innerHTML.should.be.empty;
- });
-
- it("Deselect works", function (){
- this.coll.add([{},{}]);
- var $asset = this.view.$el.children().first();
- $asset.attr('class', this.view.pfx + 'highlight');
- this.coll.trigger('deselectAll');
- $asset.attr('class').should.be.empty;
- });
-
- it("Returns not empty assets element", function (){
- obj.getAssetsEl().should.be.ok;
- });
-
- it("Returns not empty url input", function (){
- obj.getInputUrl().should.be.ok;
- });
-
- it("Add image asset from input string", function (){
- obj.getInputUrl().value = "test";
- obj.addFromStr({
- preventDefault: function(){}
- });
- var asset = obj.collection.at(0);
- asset.get('src').should.equal('test');
- });
-
- });
-
- }
- }
-});
\ No newline at end of file
+var AssetsView = require('asset_manager/view/AssetsView');
+var Assets = require('asset_manager/model/Assets');
+
+module.exports = {
+ run: function() {
+
+ describe('AssetsView', function() {
+
+ var obj;
+
+ before(function () {
+ this.$fixtures = $("#fixtures");
+ this.$fixture = $('');
+ });
+
+ beforeEach(function () {
+ this.coll = new Assets([]);
+ this.view = new AssetsView({
+ config : {},
+ collection: this.coll
+ });
+ obj = this.view;
+ this.$fixture.empty().appendTo(this.$fixtures);
+ this.$fixture.html(this.view.render().el);
+ });
+
+ afterEach(function () {
+ this.view.collection.reset();
+ });
+
+ after(function () {
+ this.$fixture.remove();
+ });
+
+ it('Object exists', function() {
+ AssetsView.should.be.exist;
+ });
+
+ it("Collection is empty", function (){
+ this.view.getAssetsEl().innerHTML.should.be.empty;
+ });
+
+ it("Add new asset", function (){
+ sinon.stub(this.view, "addAsset");
+ this.coll.add({src: 'test'});
+ this.view.addAsset.calledOnce.should.equal(true);
+ });
+
+ it("Render new asset", function (){
+ this.coll.add({src: 'test'});
+ this.view.getAssetsEl().innerHTML.should.not.be.empty;
+ });
+
+ it("Render correctly new image asset", function (){
+ this.coll.add({ type: 'image', src: 'test'});
+ var asset = this.view.getAssetsEl().firstChild;
+ asset.tagName.should.equal('DIV');
+ asset.innerHTML.should.not.be.empty;
+ });
+
+ it("Clean collection from asset", function (){
+ var model = this.coll.add({src: 'test'});
+ this.coll.remove(model);
+ this.view.getAssetsEl().innerHTML.should.be.empty;
+ });
+
+ it("Deselect works", function (){
+ this.coll.add([{},{}]);
+ var $asset = this.view.$el.children().first();
+ $asset.attr('class', this.view.pfx + 'highlight');
+ this.coll.trigger('deselectAll');
+ $asset.attr('class').should.be.empty;
+ });
+
+ it("Returns not empty assets element", function (){
+ obj.getAssetsEl().should.be.ok;
+ });
+
+ it("Returns not empty url input", function (){
+ obj.getInputUrl().should.be.ok;
+ });
+
+ it("Add image asset from input string", function (){
+ obj.getInputUrl().value = "test";
+ obj.addFromStr({
+ preventDefault: function(){}
+ });
+ var asset = obj.collection.at(0);
+ asset.get('src').should.equal('test');
+ });
+
+ });
+
+ }
+}
diff --git a/test/specs/asset_manager/view/FileUploader.js b/test/specs/asset_manager/view/FileUploader.js
index 2646b94c5..528db80d4 100644
--- a/test/specs/asset_manager/view/FileUploader.js
+++ b/test/specs/asset_manager/view/FileUploader.js
@@ -1,80 +1,77 @@
-define(function(require, exports, module){
- 'use strict';
- var FileUploader = require('AssetManager/view/FileUploader');
-
- module.exports = {
- run: function() {
-
- describe('File Uploader', function() {
-
- before(function () {
- this.$fixtures = $("#fixtures");
- this.$fixture = $('');
- });
-
- beforeEach(function () {
- this.view = new FileUploader({ config : {} });
- this.$fixture.empty().appendTo(this.$fixtures);
- this.$fixture.html(this.view.render().el);
- });
-
- afterEach(function () {
- this.view.remove();
- });
-
- after(function () {
- this.$fixture.remove();
- });
-
- it('Object exists', function() {
- FileUploader.should.be.exist;
- });
-
- it('Has correct prefix', function() {
- this.view.pfx.should.equal('');
- });
-
- describe('Should be rendered correctly', function() {
-
- it('Has title', function() {
- this.view.$el.find('#title').should.have.property(0);
- });
-
- it('Title is empty', function() {
- this.view.$el.find('#title').html().should.equal('');
- });
-
- it('Has file input', function() {
- this.view.$el.find('input[type=file]').should.have.property(0);
- });
-
- it('File input is enabled', function() {
- this.view.$el.find('input[type=file]').prop('disabled').should.equal(true);
- });
-
- });
-
- describe('Interprets configurations correctly', function() {
-
- it('Has correct title', function() {
- var view = new FileUploader({ config : {
- uploadText : 'Test',
- } });
- view.render();
- view.$el.find('#title').html().should.equal('Test');
- });
-
- it('Could be disabled', function() {
- var view = new FileUploader({ config : {
- disableUpload: true,
- } });
- view.render();
- view.$el.find('input[type=file]').prop('disabled').should.equal(true);
- });
-
- });
-
- });
- }
- }
-});
\ No newline at end of file
+var FileUploader = require('asset_manager/view/FileUploader');
+
+module.exports = {
+ run: function() {
+
+ describe('File Uploader', function() {
+
+ before(function () {
+ this.$fixtures = $("#fixtures");
+ this.$fixture = $('');
+ });
+
+ beforeEach(function () {
+ this.view = new FileUploader({ config : {} });
+ this.$fixture.empty().appendTo(this.$fixtures);
+ this.$fixture.html(this.view.render().el);
+ });
+
+ afterEach(function () {
+ this.view.remove();
+ });
+
+ after(function () {
+ this.$fixture.remove();
+ });
+
+ it('Object exists', function() {
+ FileUploader.should.be.exist;
+ });
+
+ it('Has correct prefix', function() {
+ this.view.pfx.should.equal('');
+ });
+
+ describe('Should be rendered correctly', function() {
+
+ it('Has title', function() {
+ this.view.$el.find('#title').should.have.property(0);
+ });
+
+ it('Title is empty', function() {
+ this.view.$el.find('#title').html().should.equal('');
+ });
+
+ it('Has file input', function() {
+ this.view.$el.find('input[type=file]').should.have.property(0);
+ });
+
+ it('File input is enabled', function() {
+ this.view.$el.find('input[type=file]').prop('disabled').should.equal(true);
+ });
+
+ });
+
+ describe('Interprets configurations correctly', function() {
+
+ it('Has correct title', function() {
+ var view = new FileUploader({ config : {
+ uploadText : 'Test',
+ } });
+ view.render();
+ view.$el.find('#title').html().should.equal('Test');
+ });
+
+ it('Could be disabled', function() {
+ var view = new FileUploader({ config : {
+ disableUpload: true,
+ } });
+ view.render();
+ view.$el.find('input[type=file]').prop('disabled').should.equal(true);
+ });
+
+ });
+
+ });
+ }
+}