From eaf10e8a96f5554d71bc6bc1c1b5a0cde332bea5 Mon Sep 17 00:00:00 2001 From: Pavel Dohnal Date: Wed, 16 Aug 2017 12:34:59 +0200 Subject: [PATCH] Fix no-param-reassign in tests [MAILPOET-1033] --- .eslintrc.tests.json | 1 - tests/javascript/loadHelpers.js | 8 ++++---- tests/javascript/mochaTestHelper.js | 13 +++++++------ .../blocks/automatedLatestContent.spec.js | 6 ++++-- .../newsletter_editor/blocks/button.spec.js | 3 ++- .../newsletter_editor/blocks/container.spec.js | 3 ++- .../newsletter_editor/blocks/divider.spec.js | 3 ++- .../newsletter_editor/blocks/footer.spec.js | 3 ++- .../newsletter_editor/blocks/header.spec.js | 3 ++- .../newsletter_editor/blocks/image.spec.js | 3 ++- .../newsletter_editor/blocks/posts.spec.js | 4 +++- .../newsletter_editor/blocks/spacer.spec.js | 3 ++- .../newsletter_editor/components/content.spec.js | 3 ++- .../newsletter_editor/components/save.spec.js | 3 ++- .../newsletter_editor/components/styles.spec.js | 3 ++- 15 files changed, 38 insertions(+), 24 deletions(-) diff --git a/.eslintrc.tests.json b/.eslintrc.tests.json index e4fec05649..c2b0a6b998 100644 --- a/.eslintrc.tests.json +++ b/.eslintrc.tests.json @@ -37,7 +37,6 @@ "vars-on-top": 0, "space-before-blocks": 0, "object-curly-spacing": 0, - "no-param-reassign": 0, "one-var-declaration-per-line": 0, "func-names": 0, "space-before-function-paren": 0 diff --git a/tests/javascript/loadHelpers.js b/tests/javascript/loadHelpers.js index 7fa77e4586..81af5da166 100644 --- a/tests/javascript/loadHelpers.js +++ b/tests/javascript/loadHelpers.js @@ -1,9 +1,9 @@ var fs = require('fs'); module.exports = { - loadFileToContainer: function (path, window, containerTagName, options) { + loadFileToContainer: function (path, window, containerTagName, opts) { var contents = fs.readFileSync(path), container = window.document.createElement(containerTagName); - options = options || {}; + var options = opts || {}; container.innerHTML = contents; if (options.type) { @@ -17,9 +17,9 @@ module.exports = { loadScript: function (scriptPath, window, options) { this.loadFileToContainer(scriptPath, window, 'script', options); }, - loadTemplate: function (path, window, options) { + loadTemplate: function (path, window, opts) { var w = window || global.window; - options = options || {}; + var options = opts || {}; options.type = "text/x-handlebars-template"; this.loadScript("views/newsletter/templates/" + path, w, options); diff --git a/tests/javascript/mochaTestHelper.js b/tests/javascript/mochaTestHelper.js index faf916adff..4dcc3fef1a 100644 --- a/tests/javascript/mochaTestHelper.js +++ b/tests/javascript/mochaTestHelper.js @@ -55,20 +55,21 @@ jQuery.fn.stick_in_parent = function() { return this; }; // Add global stubs for convenience // TODO: Extract those to a separate file global.stubChannel = function (EditorApplication, returnObject) { - EditorApplication.getChannel = sinon.stub().returns(_.defaults(returnObject || {}, { + var App = EditorApplication; + App.getChannel = sinon.stub().returns(_.defaults(returnObject || {}, { trigger: function () { }, on: function () { } })); }; -global.stubConfig = function (EditorApplication, config) { - config = config || {}; - EditorApplication.getConfig = sinon.stub().returns(new Backbone.SuperModel(config)); +global.stubConfig = function (EditorApplication, opts) { + var App = EditorApplication; + App.getConfig = sinon.stub().returns(new Backbone.SuperModel(opts || {})); }; global.stubAvailableStyles = function (EditorApplication, styles) { - styles = styles || {}; - EditorApplication.getAvailableStyles = sinon.stub().returns(new Backbone.SuperModel(styles)); + var App = EditorApplication; + App.getAvailableStyles = sinon.stub().returns(new Backbone.SuperModel(styles || {})); }; global.stubImage = function(defaultWidth, defaultHeight) { diff --git a/tests/javascript/newsletter_editor/blocks/automatedLatestContent.spec.js b/tests/javascript/newsletter_editor/blocks/automatedLatestContent.spec.js index 38c9d1014f..fd7ba428b8 100644 --- a/tests/javascript/newsletter_editor/blocks/automatedLatestContent.spec.js +++ b/tests/javascript/newsletter_editor/blocks/automatedLatestContent.spec.js @@ -5,12 +5,14 @@ define([ 'amd-inject-loader!newsletter_editor/blocks/automatedLatestContent', 'newsletter_editor/components/communication' ], function( - EditorApplication, + App, AutomatedLatestContentBlock, ContainerBlock, AutomatedLatestContentInjector, - CommunicationComponent + Communication ) { + var EditorApplication = App; + var CommunicationComponent = Communication; describe('Automated Latest Content Supervisor', function() { var model; diff --git a/tests/javascript/newsletter_editor/blocks/button.spec.js b/tests/javascript/newsletter_editor/blocks/button.spec.js index 2165826c30..fce7c2dae3 100644 --- a/tests/javascript/newsletter_editor/blocks/button.spec.js +++ b/tests/javascript/newsletter_editor/blocks/button.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/blocks/button' - ], function(EditorApplication, ButtonBlock) { + ], function(App, ButtonBlock) { + var EditorApplication = App; describe("Button", function () { describe("model", function () { diff --git a/tests/javascript/newsletter_editor/blocks/container.spec.js b/tests/javascript/newsletter_editor/blocks/container.spec.js index 3f2a0a689c..0c583c78fb 100644 --- a/tests/javascript/newsletter_editor/blocks/container.spec.js +++ b/tests/javascript/newsletter_editor/blocks/container.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/blocks/container' - ], function(EditorApplication, ContainerBlock) { + ], function(App, ContainerBlock) { + var EditorApplication = App; describe('Container', function () { var ModelClass = ContainerBlock.ContainerBlockModel; diff --git a/tests/javascript/newsletter_editor/blocks/divider.spec.js b/tests/javascript/newsletter_editor/blocks/divider.spec.js index b85cc46cf1..212bf7c20d 100644 --- a/tests/javascript/newsletter_editor/blocks/divider.spec.js +++ b/tests/javascript/newsletter_editor/blocks/divider.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/blocks/divider' - ], function(EditorApplication, DividerBlock) { + ], function(App, DividerBlock) { + var EditorApplication = App; describe("Divider", function () { describe("model", function () { diff --git a/tests/javascript/newsletter_editor/blocks/footer.spec.js b/tests/javascript/newsletter_editor/blocks/footer.spec.js index af6e9f1781..a2b2b8b220 100644 --- a/tests/javascript/newsletter_editor/blocks/footer.spec.js +++ b/tests/javascript/newsletter_editor/blocks/footer.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/blocks/footer' - ], function(EditorApplication, FooterBlock) { + ], function(App, FooterBlock) { + var EditorApplication = App; describe('Footer', function () { describe('model', function () { diff --git a/tests/javascript/newsletter_editor/blocks/header.spec.js b/tests/javascript/newsletter_editor/blocks/header.spec.js index e5bd25d79b..04684f1292 100644 --- a/tests/javascript/newsletter_editor/blocks/header.spec.js +++ b/tests/javascript/newsletter_editor/blocks/header.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/blocks/header' - ], function(EditorApplication, HeaderBlock) { + ], function(App, HeaderBlock) { + var EditorApplication = App; describe('Header', function () { describe('model', function () { diff --git a/tests/javascript/newsletter_editor/blocks/image.spec.js b/tests/javascript/newsletter_editor/blocks/image.spec.js index 5e93d793b8..7ab80d2009 100644 --- a/tests/javascript/newsletter_editor/blocks/image.spec.js +++ b/tests/javascript/newsletter_editor/blocks/image.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/blocks/image' - ], function(EditorApplication, ImageBlock) { + ], function(App, ImageBlock) { + var EditorApplication = App; describe('Image', function () { describe('model', function () { diff --git a/tests/javascript/newsletter_editor/blocks/posts.spec.js b/tests/javascript/newsletter_editor/blocks/posts.spec.js index e85ef66282..0dbb393861 100644 --- a/tests/javascript/newsletter_editor/blocks/posts.spec.js +++ b/tests/javascript/newsletter_editor/blocks/posts.spec.js @@ -3,7 +3,9 @@ define([ 'newsletter_editor/components/communication', 'newsletter_editor/blocks/posts', 'newsletter_editor/blocks/container' - ], function(EditorApplication, CommunicationComponent, PostsBlock, ContainerBlock) { + ], function(App, Communication, PostsBlock, ContainerBlock) { + var EditorApplication = App; + var CommunicationComponent = Communication; describe('Posts', function () { Backbone.Radio = { diff --git a/tests/javascript/newsletter_editor/blocks/spacer.spec.js b/tests/javascript/newsletter_editor/blocks/spacer.spec.js index 3d25e42e24..20a3bba8fd 100644 --- a/tests/javascript/newsletter_editor/blocks/spacer.spec.js +++ b/tests/javascript/newsletter_editor/blocks/spacer.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/blocks/spacer' - ], function(EditorApplication, SpacerBlock) { + ], function(App, SpacerBlock) { + var EditorApplication = App; describe('Spacer', function () { describe('model', function () { diff --git a/tests/javascript/newsletter_editor/components/content.spec.js b/tests/javascript/newsletter_editor/components/content.spec.js index c92a930ef1..806ef56d17 100644 --- a/tests/javascript/newsletter_editor/components/content.spec.js +++ b/tests/javascript/newsletter_editor/components/content.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/components/content' - ], function(EditorApplication, ContentComponent) { + ], function(App, ContentComponent) { + var EditorApplication = App; describe('Content', function() { describe('newsletter model', function() { diff --git a/tests/javascript/newsletter_editor/components/save.spec.js b/tests/javascript/newsletter_editor/components/save.spec.js index aac73a6dbd..05a37f9b1e 100644 --- a/tests/javascript/newsletter_editor/components/save.spec.js +++ b/tests/javascript/newsletter_editor/components/save.spec.js @@ -3,7 +3,8 @@ define([ 'newsletter_editor/components/save', 'amd-inject-loader!newsletter_editor/components/save', 'jquery' - ], function(EditorApplication, SaveComponent, SaveInjector, jQuery) { + ], function(App, SaveComponent, SaveInjector, jQuery) { + var EditorApplication = App; describe('Save', function() { describe('save method', function() { diff --git a/tests/javascript/newsletter_editor/components/styles.spec.js b/tests/javascript/newsletter_editor/components/styles.spec.js index 23258c3d02..f2647b7b03 100644 --- a/tests/javascript/newsletter_editor/components/styles.spec.js +++ b/tests/javascript/newsletter_editor/components/styles.spec.js @@ -1,7 +1,8 @@ define([ 'newsletter_editor/App', 'newsletter_editor/components/styles' - ], function(EditorApplication, StylesComponent) { + ], function(App, StylesComponent) { + var EditorApplication = App; describe('Styles', function () { it('loads and stores globally available styles', function() {