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:
Jarek Radosz
2020-10-30 17:37:32 +01:00
committed by GitHub
parent d5fb0b9435
commit a17d54d0bf
185 changed files with 762 additions and 762 deletions

View File

@ -4,7 +4,7 @@ acceptance("Local Dates - composer", function (needs) {
needs.user();
needs.settings({ discourse_local_dates_enabled: true });
test("composer bbcode", async (assert) => {
test("composer bbcode", async function (assert) {
const getAttr = (attr) => {
return queryAll(
".d-editor-preview .discourse-local-date.cooked-date"

View File

@ -17,7 +17,7 @@ function buildDateHelper(params = {}) {
});
}
test("#format", (assert) => {
test("#format", function (assert) {
let date = buildDateHelper({
day: 15,
month: 2,
@ -28,7 +28,7 @@ test("#format", (assert) => {
assert.equal(date.format(), "2020-03-15T15:36:00.000+01:00");
});
test("#repetitionsBetweenDates", (assert) => {
test("#repetitionsBetweenDates", function (assert) {
let date;
date = buildDateHelper({
@ -96,7 +96,7 @@ test("#repetitionsBetweenDates", (assert) => {
);
});
test("#add", (assert) => {
test("#add", function (assert) {
let date;
let futureLocalDate;

View File

@ -61,7 +61,7 @@ QUnit.assert.buildsCorrectDate = function (options, expected, message) {
}
};
test("date", (assert) => {
test("date", function (assert) {
freezeTime({ date: "2020-03-11" }, () => {
assert.buildsCorrectDate(
{ date: "2020-03-22", timezone: PARIS },
@ -71,7 +71,7 @@ test("date", (assert) => {
});
});
test("date and time", (assert) => {
test("date and time", function (assert) {
assert.buildsCorrectDate(
{ date: "2020-04-11", time: "11:00" },
{ formated: "April 11, 2020 1:00 PM" },
@ -85,7 +85,7 @@ test("date and time", (assert) => {
);
});
test("option[format]", (assert) => {
test("option[format]", function (assert) {
freezeTime({ date: "2020-03-11" }, () => {
assert.buildsCorrectDate(
{ format: "YYYY" },
@ -95,7 +95,7 @@ test("option[format]", (assert) => {
});
});
test("option[displayedTimezone]", (assert) => {
test("option[displayedTimezone]", function (assert) {
freezeTime({}, () => {
assert.buildsCorrectDate(
{ displayedTimezone: SYDNEY },
@ -129,7 +129,7 @@ test("option[displayedTimezone]", (assert) => {
});
});
test("option[timezone]", (assert) => {
test("option[timezone]", function (assert) {
freezeTime({}, () => {
assert.buildsCorrectDate(
{ timezone: SYDNEY, displayedTimezone: PARIS },
@ -139,7 +139,7 @@ test("option[timezone]", (assert) => {
});
});
test("option[recurring]", (assert) => {
test("option[recurring]", function (assert) {
freezeTime({ date: "2020-04-06 06:00", timezone: LAGOS }, () => {
assert.buildsCorrectDate(
{
@ -219,7 +219,7 @@ test("option[recurring]", (assert) => {
});
});
test("option[countown]", (assert) => {
test("option[countown]", function (assert) {
freezeTime({ date: "2020-03-21 23:59" }, () => {
assert.buildsCorrectDate(
{
@ -247,7 +247,7 @@ test("option[countown]", (assert) => {
});
});
test("option[calendar]", (assert) => {
test("option[calendar]", function (assert) {
freezeTime({ date: "2020-03-23 23:00" }, () => {
assert.buildsCorrectDate(
{ date: "2020-03-22", time: "23:59", timezone: PARIS },
@ -328,7 +328,7 @@ test("option[calendar]", (assert) => {
});
});
test("previews", (assert) => {
test("previews", function (assert) {
freezeTime({ date: "2020-03-22" }, () => {
assert.buildsCorrectDate(
{ timezone: PARIS },