mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 20:18:23 -05:00
DEV: apply new coding standards (#10592)
This commit is contained in:
@@ -9,16 +9,16 @@ QUnit.module("Acceptance: wizard", {
|
||||
|
||||
afterEach() {
|
||||
run(wizard, "destroy");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
test("Wizard starts", async assert => {
|
||||
test("Wizard starts", async (assert) => {
|
||||
await visit("/");
|
||||
assert.ok(exists(".wizard-column-contents"));
|
||||
assert.equal(currentPath(), "step");
|
||||
});
|
||||
|
||||
test("Going back and forth in steps", async assert => {
|
||||
test("Going back and forth in steps", async (assert) => {
|
||||
await visit("/steps/hello-world");
|
||||
assert.ok(exists(".wizard-step"));
|
||||
assert.ok(
|
||||
|
||||
@@ -72,5 +72,5 @@ componentTest("can add users", {
|
||||
find(".users-list .invite-list-user").length === 0,
|
||||
"removed the user"
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import initializer from "wizard/initializers/load-helpers";
|
||||
export function componentTest(name, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
test(name, function(assert) {
|
||||
test(name, function (assert) {
|
||||
initializer.initialize(this.registry);
|
||||
|
||||
if (opts.beforeEach) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import initializer from "wizard/initializers/load-helpers";
|
||||
let app;
|
||||
let started = false;
|
||||
|
||||
export default function() {
|
||||
export default function () {
|
||||
run(() => (app = Wizard.create({ rootElement: "#ember-testing" })));
|
||||
|
||||
if (!started) {
|
||||
|
||||
@@ -2,14 +2,14 @@ import WizardField from "wizard/models/wizard-field";
|
||||
|
||||
moduleFor("model:wizard-field");
|
||||
|
||||
test("basic state", assert => {
|
||||
test("basic state", (assert) => {
|
||||
const w = WizardField.create({ type: "text" });
|
||||
assert.ok(w.get("unchecked"));
|
||||
assert.ok(!w.get("valid"));
|
||||
assert.ok(!w.get("invalid"));
|
||||
});
|
||||
|
||||
test("text - required - validation", assert => {
|
||||
test("text - required - validation", (assert) => {
|
||||
const w = WizardField.create({ type: "text", required: true });
|
||||
assert.ok(w.get("unchecked"));
|
||||
|
||||
@@ -25,7 +25,7 @@ test("text - required - validation", assert => {
|
||||
assert.ok(!w.get("invalid"));
|
||||
});
|
||||
|
||||
test("text - optional - validation", assert => {
|
||||
test("text - optional - validation", (assert) => {
|
||||
const f = WizardField.create({ type: "text" });
|
||||
assert.ok(f.get("unchecked"));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// discourse-skip-module
|
||||
/*global document, sinon, Logster, QUnit */
|
||||
/*global document, Logster, QUnit */
|
||||
|
||||
//= require env
|
||||
//= require jquery.debug
|
||||
@@ -49,11 +49,11 @@ var createPretendServer = requirejs(
|
||||
).default;
|
||||
|
||||
var server;
|
||||
QUnit.testStart(function() {
|
||||
QUnit.testStart(function () {
|
||||
server = createPretendServer();
|
||||
});
|
||||
|
||||
QUnit.testDone(function() {
|
||||
QUnit.testDone(function () {
|
||||
server.shutdown();
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ 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) {
|
||||
Object.keys(requirejs.entries).forEach(function (entry) {
|
||||
if (/\-test/.test(entry)) {
|
||||
requirejs(entry, null, null, true);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
function parsePostData(query) {
|
||||
const result = {};
|
||||
query.split("&").forEach(function(part) {
|
||||
query.split("&").forEach(function (part) {
|
||||
const item = part.split("=");
|
||||
const firstSeg = decodeURIComponent(item[0]);
|
||||
const m = /^([^\[]+)\[([^\]]+)\]/.exec(firstSeg);
|
||||
@@ -27,8 +27,8 @@ function response(code, obj) {
|
||||
return [code, { "Content-Type": "application/json" }, obj];
|
||||
}
|
||||
|
||||
export default function() {
|
||||
const server = new Pretender(function() {
|
||||
export default function () {
|
||||
const server = new Pretender(function () {
|
||||
this.get("/wizard.json", () => {
|
||||
return response(200, {
|
||||
wizard: {
|
||||
@@ -45,10 +45,10 @@ export default function() {
|
||||
id: "full_name",
|
||||
type: "text",
|
||||
required: true,
|
||||
description: "Your name"
|
||||
}
|
||||
description: "Your name",
|
||||
},
|
||||
],
|
||||
next: "second-step"
|
||||
next: "second-step",
|
||||
},
|
||||
{
|
||||
id: "second-step",
|
||||
@@ -56,7 +56,7 @@ export default function() {
|
||||
index: 1,
|
||||
fields: [{ id: "some-title", type: "text" }],
|
||||
previous: "hello-world",
|
||||
next: "last-step"
|
||||
next: "last-step",
|
||||
},
|
||||
{
|
||||
id: "last-step",
|
||||
@@ -64,21 +64,21 @@ export default function() {
|
||||
fields: [
|
||||
{ id: "snack", type: "dropdown", required: true },
|
||||
{ id: "theme-preview", type: "component" },
|
||||
{ id: "an-image", type: "image" }
|
||||
{ id: "an-image", type: "image" },
|
||||
],
|
||||
previous: "second-step"
|
||||
}
|
||||
]
|
||||
}
|
||||
previous: "second-step",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
this.put("/wizard/steps/:id", request => {
|
||||
this.put("/wizard/steps/:id", (request) => {
|
||||
const body = parsePostData(request.requestBody);
|
||||
|
||||
if (body.fields.full_name === "Server Fail") {
|
||||
return response(422, {
|
||||
errors: [{ field: "full_name", description: "Invalid name" }]
|
||||
errors: [{ field: "full_name", description: "Invalid name" }],
|
||||
});
|
||||
} else {
|
||||
return response(200, { success: true });
|
||||
@@ -86,14 +86,14 @@ export default function() {
|
||||
});
|
||||
});
|
||||
|
||||
server.prepareBody = function(body) {
|
||||
server.prepareBody = function (body) {
|
||||
if (body && typeof body === "object") {
|
||||
return JSON.stringify(body);
|
||||
}
|
||||
return body;
|
||||
};
|
||||
|
||||
server.unhandledRequest = function(verb, path) {
|
||||
server.unhandledRequest = function (verb, path) {
|
||||
const error =
|
||||
"Unhandled request in test environment: " + path + " (" + verb + ")";
|
||||
window.console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user