mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: De-arrowify tests (#11068)
Using arrow functions changes `this` context, which is undesired in tests, e.g. it makes it impossible to setup things like pretender (`this.server`) in `beforeEach` hooks. Ember guides always use classic functions in examples (e.g. https://guides.emberjs.com/release/testing/test-types/), and that's what it uses in its own test suite, as do various addons and ember apps. It was also already used in Discourse where `this` was required. Moving forward, it will be needed in more places as we migrate toward ember-cli. (I might later add a custom rule to eslint-discourse-ember to enforce this)
This commit is contained in:
@@ -18,13 +18,13 @@ function exists(selector) {
|
||||
return document.querySelector(selector) !== null;
|
||||
}
|
||||
|
||||
test("Wizard starts", async (assert) => {
|
||||
test("Wizard starts", async function (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 function (assert) {
|
||||
await visit("/steps/hello-world");
|
||||
assert.ok(exists(".wizard-step"));
|
||||
assert.ok(
|
||||
|
||||
@@ -4,14 +4,14 @@ import WizardField from "wizard/models/wizard-field";
|
||||
|
||||
moduleFor("model:wizard-field");
|
||||
|
||||
test("basic state", (assert) => {
|
||||
test("basic state", function (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", function (assert) {
|
||||
const w = WizardField.create({ type: "text", required: true });
|
||||
assert.ok(w.get("unchecked"));
|
||||
|
||||
@@ -27,7 +27,7 @@ test("text - required - validation", (assert) => {
|
||||
assert.ok(!w.get("invalid"));
|
||||
});
|
||||
|
||||
test("text - optional - validation", (assert) => {
|
||||
test("text - optional - validation", function (assert) {
|
||||
const f = WizardField.create({ type: "text" });
|
||||
assert.ok(f.get("unchecked"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user