Fix eslint errors in newsletter tests helper files
[MAILPOET-3752]
This commit is contained in:
committed by
Veljko V
parent
d6cdbc844d
commit
a5272d58e7
@@ -1,6 +1,6 @@
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
loadFileToContainer: function (path, window, containerTagName, opts) {
|
loadFileToContainer: function loadFileToContainer(path, window, containerTagName, opts) {
|
||||||
var contents = fs.readFileSync(path);
|
var contents = fs.readFileSync(path);
|
||||||
var container = window.document.createElement(containerTagName);
|
var container = window.document.createElement(containerTagName);
|
||||||
var options = opts || {};
|
var options = opts || {};
|
||||||
@@ -14,10 +14,10 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
global.window.document.body.appendChild(container);
|
global.window.document.body.appendChild(container);
|
||||||
},
|
},
|
||||||
loadScript: function (scriptPath, window, options) {
|
loadScript: function loadScript(scriptPath, window, options) {
|
||||||
this.loadFileToContainer(scriptPath, window, 'script', options);
|
this.loadFileToContainer(scriptPath, window, 'script', options);
|
||||||
},
|
},
|
||||||
loadTemplate: function (path, window, opts) {
|
loadTemplate: function loadTemplate(path, window, opts) {
|
||||||
var w = window || global.window;
|
var w = window || global.window;
|
||||||
var options = opts || {};
|
var options = opts || {};
|
||||||
options.type = 'text/x-handlebars-template';
|
options.type = 'text/x-handlebars-template';
|
||||||
|
@@ -30,6 +30,7 @@ if (!global.document || !global.window) {
|
|||||||
}
|
}
|
||||||
const testHelpers = require('./loadHelpers.js');
|
const testHelpers = require('./loadHelpers.js');
|
||||||
global.testHelpers = testHelpers;
|
global.testHelpers = testHelpers;
|
||||||
|
|
||||||
const jQuery = require('jquery');
|
const jQuery = require('jquery');
|
||||||
global.$ = jQuery;
|
global.$ = jQuery;
|
||||||
global.jQuery = jQuery;
|
global.jQuery = jQuery;
|
||||||
@@ -46,7 +47,7 @@ global.Node = global.window.Node;
|
|||||||
global.HTMLAnchorElement = global.window.HTMLAnchorElement;
|
global.HTMLAnchorElement = global.window.HTMLAnchorElement;
|
||||||
|
|
||||||
// Stub out interact.js
|
// Stub out interact.js
|
||||||
global.interact = function () {
|
global.interact = () => {
|
||||||
return {
|
return {
|
||||||
draggable: global.interact,
|
draggable: global.interact,
|
||||||
restrict: global.interact,
|
restrict: global.interact,
|
||||||
@@ -58,44 +59,40 @@ global.interact = function () {
|
|||||||
styleCursor: global.interact,
|
styleCursor: global.interact,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
global.spectrum = function () { return this; };
|
global.spectrum = function spectrum() { return this; };
|
||||||
jQuery.fn.spectrum = global.spectrum;
|
jQuery.fn.spectrum = global.spectrum;
|
||||||
|
|
||||||
// Add global stubs for convenience
|
// Add global stubs for convenience
|
||||||
global.stubChannel = function (EditorApplication, returnObject) {
|
global.stubChannel = (EditorApplication, returnObject) => {
|
||||||
var App = EditorApplication;
|
var App = EditorApplication;
|
||||||
App.getChannel = sinon.stub().returns(_.defaults(returnObject || {}, {
|
App.getChannel = sinon.stub().returns(_.defaults(returnObject || {}, {
|
||||||
request: function () {
|
request: () => {},
|
||||||
},
|
trigger: () => {},
|
||||||
trigger: function () {
|
on: () => {},
|
||||||
},
|
off: () => {},
|
||||||
on: function () {
|
|
||||||
},
|
|
||||||
off: function () {
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
global.stubConfig = function (EditorApplication, opts) {
|
global.stubConfig = (EditorApplication, opts) => {
|
||||||
var App = EditorApplication;
|
var App = EditorApplication;
|
||||||
App.getConfig = sinon.stub().returns(new global.Backbone.SuperModel(opts || {}));
|
App.getConfig = sinon.stub().returns(new global.Backbone.SuperModel(opts || {}));
|
||||||
};
|
};
|
||||||
global.stubAvailableStyles = function (EditorApplication, styles) {
|
global.stubAvailableStyles = (EditorApplication, styles) => {
|
||||||
var App = EditorApplication;
|
var App = EditorApplication;
|
||||||
App.getAvailableStyles = sinon.stub().returns(new global.Backbone.SuperModel(styles || {}));
|
App.getAvailableStyles = sinon.stub().returns(new global.Backbone.SuperModel(styles || {}));
|
||||||
};
|
};
|
||||||
|
|
||||||
global.stubImage = function (defaultWidth, defaultHeight) {
|
global.stubImage = function stubImage(defaultWidth, defaultHeight) {
|
||||||
global.Image = function () {
|
global.Image = function Image() {
|
||||||
this.onload = function () {};
|
this.onload = () => {};
|
||||||
this.naturalWidth = defaultWidth;
|
this.naturalWidth = defaultWidth;
|
||||||
this.naturalHeight = defaultHeight;
|
this.naturalHeight = defaultHeight;
|
||||||
this.address = '';
|
this.address = '';
|
||||||
|
|
||||||
Object.defineProperty(this, 'src', {
|
Object.defineProperty(this, 'src', {
|
||||||
get: function () {
|
get: function get() {
|
||||||
return this.address;
|
return this.address;
|
||||||
},
|
},
|
||||||
set: function (src) {
|
set: function set(src) {
|
||||||
this.address = src;
|
this.address = src;
|
||||||
this.onload();
|
this.onload();
|
||||||
},
|
},
|
||||||
@@ -118,7 +115,7 @@ global.window.matchMedia = window.matchMedia || (
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
global.window.fontsSelect = function () {};
|
global.window.fontsSelect = () => {};
|
||||||
|
|
||||||
testHelpers.loadTemplate('blocks/base/toolsGeneric.hbs', window, { id: 'newsletter_editor_template_tools_generic' });
|
testHelpers.loadTemplate('blocks/base/toolsGeneric.hbs', window, { id: 'newsletter_editor_template_tools_generic' });
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user