Apply prettier.

This commit is contained in:
Guo Xiang Tan 2018-09-07 15:19:34 +08:00
parent 89e5d91f0a
commit 039afe0d2c
2 changed files with 51 additions and 34 deletions

View File

@ -22,11 +22,14 @@
//= require pretender
//= require ./wizard-pretender
// Trick JSHint into allow document.write
var d = document;
d.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
d.write('<style>#ember-testing-container { position: absolute; background: white; bottom: 0; right: 0; width: 640px; height: 384px; overflow: auto; z-index: 9999; border: 1px solid #ccc; } #ember-testing { zoom: 50%; }</style>');
d.write(
'<div id="ember-testing-container"><div id="ember-testing"></div></div>'
);
d.write(
"<style>#ember-testing-container { position: absolute; background: white; bottom: 0; right: 0; width: 640px; height: 384px; overflow: auto; z-index: 9999; border: 1px solid #ccc; } #ember-testing { zoom: 50%; }</style>"
);
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);
}
});

View File

@ -52,12 +52,16 @@ window.MessageBus.stop();
// Trick JSHint into allow document.write
var d = document;
d.write('<script src="/javascripts/ace/ace.js"></script>');
d.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
d.write('<style>#ember-testing-container { position: absolute; background: white; bottom: 0; right: 0; width: 640px; height: 384px; overflow: auto; z-index: 9999; border: 1px solid #ccc; } #ember-testing { zoom: 50%; }</style>');
d.write(
'<div id="ember-testing-container"><div id="ember-testing"></div></div>'
);
d.write(
"<style>#ember-testing-container { position: absolute; background: white; bottom: 0; right: 0; width: 640px; height: 384px; overflow: auto; z-index: 9999; border: 1px solid #ccc; } #ember-testing { zoom: 50%; }</style>"
);
Ember.Test.adapter = window.QUnitAdapter.create();
Discourse.rootElement = '#ember-testing';
Discourse.rootElement = "#ember-testing";
Discourse.setupForTesting();
Discourse.injectTestHelpers();
Discourse.start();
@ -70,12 +74,14 @@ 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,
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) {
@ -83,8 +89,8 @@ function dup(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 + '=([^&#]*)');
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
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)) {