From 039afe0d2c50c22aa1f2ad25afe907a5ce752e6f Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 7 Sep 2018 15:19:34 +0800 Subject: [PATCH] Apply prettier. --- .../javascripts/wizard/test/test_helper.js | 25 +++++--- test/javascripts/test_helper.js | 60 +++++++++++-------- 2 files changed, 51 insertions(+), 34 deletions(-) diff --git a/app/assets/javascripts/wizard/test/test_helper.js b/app/assets/javascripts/wizard/test/test_helper.js index 91abd402c94..f2281cea0e8 100644 --- a/app/assets/javascripts/wizard/test/test_helper.js +++ b/app/assets/javascripts/wizard/test/test_helper.js @@ -22,11 +22,14 @@ //= require pretender //= require ./wizard-pretender - // Trick JSHint into allow document.write var d = document; -d.write('
'); -d.write(''); +d.write( + '
' +); +d.write( + "" +); if (window.Logster) { Logster.enabled = false; @@ -35,7 +38,12 @@ if (window.Logster) { } Ember.Test.adapter = window.QUnitAdapter.create(); -var createPretendServer = requirejs('wizard/test/wizard-pretender', null, null, false).default; +var createPretendServer = requirejs( + "wizard/test/wizard-pretender", + null, + null, + false +).default; var server; QUnit.testStart(function() { @@ -46,13 +54,12 @@ QUnit.testDone(function() { server.shutdown(); }); - -var _testApp = requirejs('wizard/test/helpers/start-app').default(); -var _buildResolver = requirejs('discourse-common/resolver').buildResolver; -window.setResolver(_buildResolver('wizard').create({ namespace: _testApp })); +var _testApp = requirejs("wizard/test/helpers/start-app").default(); +var _buildResolver = requirejs("discourse-common/resolver").buildResolver; +window.setResolver(_buildResolver("wizard").create({ namespace: _testApp })); Object.keys(requirejs.entries).forEach(function(entry) { - if ((/\-test/).test(entry)) { + if (/\-test/.test(entry)) { requirejs(entry, null, null, true); } }); diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js index b728169e110..c24d425fdd2 100644 --- a/test/javascripts/test_helper.js +++ b/test/javascripts/test_helper.js @@ -52,12 +52,16 @@ window.MessageBus.stop(); // Trick JSHint into allow document.write var d = document; d.write(''); -d.write('
'); -d.write(''); +d.write( + '
' +); +d.write( + "" +); Ember.Test.adapter = window.QUnitAdapter.create(); -Discourse.rootElement = '#ember-testing'; +Discourse.rootElement = "#ember-testing"; Discourse.setupForTesting(); Discourse.injectTestHelpers(); Discourse.start(); @@ -70,21 +74,23 @@ if (window.Logster) { } var origDebounce = Ember.run.debounce, - pretender = require('helpers/create-pretender', null, null, false), - fixtures = require('fixtures/site-fixtures', null, null, false).default, - flushMap = require('discourse/models/store', null, null, false).flushMap, - ScrollingDOMMethods = require('discourse/mixins/scrolling', null, null, false).ScrollingDOMMethods, - _DiscourseURL = require('discourse/lib/url', null, null, false).default, - applyPretender = require('helpers/qunit-helpers', null, null, false).applyPretender, - server; + pretender = require("helpers/create-pretender", null, null, false), + fixtures = require("fixtures/site-fixtures", null, null, false).default, + flushMap = require("discourse/models/store", null, null, false).flushMap, + ScrollingDOMMethods = require("discourse/mixins/scrolling", null, null, false) + .ScrollingDOMMethods, + _DiscourseURL = require("discourse/lib/url", null, null, false).default, + applyPretender = require("helpers/qunit-helpers", null, null, false) + .applyPretender, + server; function dup(obj) { return jQuery.extend(true, {}, obj); } function resetSite(siteSettings, extras) { - var createStore = require('helpers/create-store').default; - var siteAttrs = $.extend({}, fixtures['site.json'].site, extras || {}); + var createStore = require("helpers/create-store").default; + var siteAttrs = $.extend({}, fixtures["site.json"].site, extras || {}); siteAttrs.store = createStore(); siteAttrs.siteSettings = siteSettings; Discourse.Site.resetCurrent(Discourse.Site.create(siteAttrs)); @@ -114,7 +120,7 @@ QUnit.testStart(function(ctx) { _DiscourseURL.redirectedTo = url; }; - var ps = require('preload-store').default; + var ps = require("preload-store").default; ps.reset(); window.sandbox = sinon.sandbox.create(); @@ -123,10 +129,10 @@ QUnit.testStart(function(ctx) { window.sandbox.stub(ScrollingDOMMethods, "unbindOnScroll"); // Unless we ever need to test this, let's leave it off. - $.fn.autocomplete = function() { }; + $.fn.autocomplete = function() {}; // Don't debounce in test unless we're testing debouncing - if (ctx.module.indexOf('debounce') === -1) { + if (ctx.module.indexOf("debounce") === -1) { Ember.run.debounce = Ember.run; } }); @@ -136,7 +142,7 @@ QUnit.testDone(function() { window.sandbox.restore(); // Destroy any modals - $('.modal-backdrop').remove(); + $(".modal-backdrop").remove(); flushMap(); server.shutdown(); @@ -151,18 +157,22 @@ window.controllerFor = helpers.controllerFor; window.fixture = helpers.fixture; function getUrlParameter(name) { - name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); - var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); - var results = regex.exec(location.search); - return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); -}; + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); + var results = regex.exec(location.search); + return results === null + ? "" + : decodeURIComponent(results[1].replace(/\+/g, " ")); +} -var skipCore = (getUrlParameter('qunit_skip_core') == '1'); -var pluginPath = getUrlParameter('qunit_single_plugin') ? "\/"+getUrlParameter('qunit_single_plugin')+"\/" : "\/plugins\/"; +var skipCore = getUrlParameter("qunit_skip_core") == "1"; +var pluginPath = getUrlParameter("qunit_single_plugin") + ? "/" + getUrlParameter("qunit_single_plugin") + "/" + : "/plugins/"; Object.keys(requirejs.entries).forEach(function(entry) { - var isTest = (/\-test/).test(entry); - var regex = new RegExp(pluginPath) + var isTest = /\-test/.test(entry); + var regex = new RegExp(pluginPath); var isPlugin = regex.test(entry); if (isTest && (!skipCore || isPlugin)) {