Browse Source

Adding tests for the optional assets url input

pull/2602/head
Juan 7 years ago
parent
commit
377ed27484
  1. 2
      src/asset_manager/view/AssetsView.js
  2. 65
      test/specs/asset_manager/view/AssetsView.js

2
src/asset_manager/view/AssetsView.js

@ -56,7 +56,7 @@ export default Backbone.View.extend({
const url = input.value.trim();
const handleAdd = this.config.handleAdd;
if (!url) {
if (!url || !input) {
return;
}

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

@ -14,7 +14,6 @@ describe('AssetsView', () => {
globalCollection: new Assets([]),
fu: new FileUploader({})
});
obj = obj;
document.body.innerHTML = '<div id="fixtures"></div>';
obj.render();
document.body.querySelector('#fixtures').appendChild(obj.el);
@ -68,16 +67,64 @@ describe('AssetsView', () => {
expect(obj.getAssetsEl()).toBeTruthy();
});
test('Returns not empty url input', () => {
expect(obj.getAddInput()).toBeTruthy();
describe('Assets input is enabled', () => {
var obj;
var coll;
coll = new Assets([]);
beforeEach(() => {
var config = {
showUrlInput: true
};
obj = new AssetsView({
config: config,
collection: coll,
globalCollection: new Assets([]),
fu: new FileUploader({})
});
document.body.innerHTML = '<div id="fixtures"></div>';
obj.render();
document.body.querySelector('#fixtures').appendChild(obj.el);
});
test('Returns not empty url input', () => {
expect(obj.getAddInput()).toBeTruthy();
});
test('Add image asset from input string', () => {
obj.getAddInput().value = 'test';
obj.handleSubmit({
preventDefault() {}
});
var asset = obj.options.globalCollection.at(0);
expect(asset.get('src')).toEqual('test');
});
});
test('Add image asset from input string', () => {
obj.getAddInput().value = 'test';
obj.handleSubmit({
preventDefault() {}
describe('Assets inputs is disabled', () => {
var obj;
var coll;
beforeEach(() => {
var config = {
showUrlInput: false
};
coll = new Assets([]);
obj = new AssetsView({
config: config,
collection: coll,
globalCollection: new Assets([]),
fu: new FileUploader({})
});
document.body.innerHTML = '<div id="fixtures"></div>';
obj.render();
document.body.querySelector('#fixtures').appendChild(obj.el);
});
test('No presence of url input', () => {
expect(obj.getAddInput()).toBeFalsy();
});
var asset = obj.options.globalCollection.at(0);
expect(asset.get('src')).toEqual('test');
});
});

Loading…
Cancel
Save