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 pretender
//= require ./wizard-pretender //= require ./wizard-pretender
// Trick JSHint into allow document.write // Trick JSHint into allow document.write
var d = document; var d = document;
d.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>'); d.write(
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>'); '<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) { if (window.Logster) {
Logster.enabled = false; Logster.enabled = false;
@ -35,7 +38,12 @@ if (window.Logster) {
} }
Ember.Test.adapter = window.QUnitAdapter.create(); 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; var server;
QUnit.testStart(function() { QUnit.testStart(function() {
@ -46,13 +54,12 @@ QUnit.testDone(function() {
server.shutdown(); server.shutdown();
}); });
var _testApp = requirejs("wizard/test/helpers/start-app").default();
var _testApp = requirejs('wizard/test/helpers/start-app').default(); var _buildResolver = requirejs("discourse-common/resolver").buildResolver;
var _buildResolver = requirejs('discourse-common/resolver').buildResolver; window.setResolver(_buildResolver("wizard").create({ namespace: _testApp }));
window.setResolver(_buildResolver('wizard').create({ namespace: _testApp }));
Object.keys(requirejs.entries).forEach(function(entry) { Object.keys(requirejs.entries).forEach(function(entry) {
if ((/\-test/).test(entry)) { if (/\-test/.test(entry)) {
requirejs(entry, null, null, true); requirejs(entry, null, null, true);
} }
}); });

View File

@ -52,12 +52,16 @@ window.MessageBus.stop();
// Trick JSHint into allow document.write // Trick JSHint into allow document.write
var d = document; var d = document;
d.write('<script src="/javascripts/ace/ace.js"></script>'); d.write('<script src="/javascripts/ace/ace.js"></script>');
d.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>'); d.write(
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>'); '<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(); Ember.Test.adapter = window.QUnitAdapter.create();
Discourse.rootElement = '#ember-testing'; Discourse.rootElement = "#ember-testing";
Discourse.setupForTesting(); Discourse.setupForTesting();
Discourse.injectTestHelpers(); Discourse.injectTestHelpers();
Discourse.start(); Discourse.start();
@ -70,12 +74,14 @@ if (window.Logster) {
} }
var origDebounce = Ember.run.debounce, var origDebounce = Ember.run.debounce,
pretender = require('helpers/create-pretender', null, null, false), pretender = require("helpers/create-pretender", null, null, false),
fixtures = require('fixtures/site-fixtures', null, null, false).default, fixtures = require("fixtures/site-fixtures", null, null, false).default,
flushMap = require('discourse/models/store', null, null, false).flushMap, flushMap = require("discourse/models/store", null, null, false).flushMap,
ScrollingDOMMethods = require('discourse/mixins/scrolling', null, null, false).ScrollingDOMMethods, ScrollingDOMMethods = require("discourse/mixins/scrolling", null, null, false)
_DiscourseURL = require('discourse/lib/url', null, null, false).default, .ScrollingDOMMethods,
applyPretender = require('helpers/qunit-helpers', null, null, false).applyPretender, _DiscourseURL = require("discourse/lib/url", null, null, false).default,
applyPretender = require("helpers/qunit-helpers", null, null, false)
.applyPretender,
server; server;
function dup(obj) { function dup(obj) {
@ -83,8 +89,8 @@ function dup(obj) {
} }
function resetSite(siteSettings, extras) { function resetSite(siteSettings, extras) {
var createStore = require('helpers/create-store').default; var createStore = require("helpers/create-store").default;
var siteAttrs = $.extend({}, fixtures['site.json'].site, extras || {}); var siteAttrs = $.extend({}, fixtures["site.json"].site, extras || {});
siteAttrs.store = createStore(); siteAttrs.store = createStore();
siteAttrs.siteSettings = siteSettings; siteAttrs.siteSettings = siteSettings;
Discourse.Site.resetCurrent(Discourse.Site.create(siteAttrs)); Discourse.Site.resetCurrent(Discourse.Site.create(siteAttrs));
@ -114,7 +120,7 @@ QUnit.testStart(function(ctx) {
_DiscourseURL.redirectedTo = url; _DiscourseURL.redirectedTo = url;
}; };
var ps = require('preload-store').default; var ps = require("preload-store").default;
ps.reset(); ps.reset();
window.sandbox = sinon.sandbox.create(); window.sandbox = sinon.sandbox.create();
@ -126,7 +132,7 @@ QUnit.testStart(function(ctx) {
$.fn.autocomplete = function() {}; $.fn.autocomplete = function() {};
// Don't debounce in test unless we're testing debouncing // 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; Ember.run.debounce = Ember.run;
} }
}); });
@ -136,7 +142,7 @@ QUnit.testDone(function() {
window.sandbox.restore(); window.sandbox.restore();
// Destroy any modals // Destroy any modals
$('.modal-backdrop').remove(); $(".modal-backdrop").remove();
flushMap(); flushMap();
server.shutdown(); server.shutdown();
@ -151,18 +157,22 @@ window.controllerFor = helpers.controllerFor;
window.fixture = helpers.fixture; window.fixture = helpers.fixture;
function getUrlParameter(name) { function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search); 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 skipCore = getUrlParameter("qunit_skip_core") == "1";
var pluginPath = getUrlParameter('qunit_single_plugin') ? "\/"+getUrlParameter('qunit_single_plugin')+"\/" : "\/plugins\/"; var pluginPath = getUrlParameter("qunit_single_plugin")
? "/" + getUrlParameter("qunit_single_plugin") + "/"
: "/plugins/";
Object.keys(requirejs.entries).forEach(function(entry) { Object.keys(requirejs.entries).forEach(function(entry) {
var isTest = (/\-test/).test(entry); var isTest = /\-test/.test(entry);
var regex = new RegExp(pluginPath) var regex = new RegExp(pluginPath);
var isPlugin = regex.test(entry); var isPlugin = regex.test(entry);
if (isTest && (!skipCore || isPlugin)) { if (isTest && (!skipCore || isPlugin)) {