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

@ -58,7 +58,7 @@ acceptance("Poll breakdown", function (needs) {
);
});
test("Displaying the poll breakdown modal", async (assert) => {
test("Displaying the poll breakdown modal", async function (assert) {
await visit("/t/-/topic_with_pie_chart_poll");
assert.equal(
@ -87,7 +87,7 @@ acceptance("Poll breakdown", function (needs) {
);
});
test("Changing the display mode from percentage to count", async (assert) => {
test("Changing the display mode from percentage to count", async function (assert) {
await visit("/t/-/topic_with_pie_chart_poll");
await click(".poll-show-breakdown:first");

View File

@ -14,7 +14,7 @@ acceptance("Poll Builder - polls are disabled", function (needs) {
});
needs.hooks.beforeEach(() => clearPopupMenuOptionsCallback());
test("regular user - sufficient trust level", async (assert) => {
test("regular user - sufficient trust level", async function (assert) {
updateCurrentUser({ moderator: false, admin: false, trust_level: 3 });
await displayPollBuilderButton();
@ -25,7 +25,7 @@ acceptance("Poll Builder - polls are disabled", function (needs) {
);
});
test("regular user - insufficient trust level", async (assert) => {
test("regular user - insufficient trust level", async function (assert) {
updateCurrentUser({ moderator: false, admin: false, trust_level: 1 });
await displayPollBuilderButton();
@ -36,7 +36,7 @@ acceptance("Poll Builder - polls are disabled", function (needs) {
);
});
test("staff", async (assert) => {
test("staff", async function (assert) {
updateCurrentUser({ moderator: true });
await displayPollBuilderButton();

View File

@ -16,7 +16,7 @@ acceptance("Poll Builder - polls are enabled", function (needs) {
});
needs.hooks.beforeEach(() => clearPopupMenuOptionsCallback());
test("regular user - sufficient trust level", async (assert) => {
test("regular user - sufficient trust level", async function (assert) {
updateCurrentUser({ moderator: false, admin: false, trust_level: 1 });
await displayPollBuilderButton();
@ -27,7 +27,7 @@ acceptance("Poll Builder - polls are enabled", function (needs) {
);
});
test("regular user - insufficient trust level", async (assert) => {
test("regular user - insufficient trust level", async function (assert) {
updateCurrentUser({ moderator: false, admin: false, trust_level: 0 });
await displayPollBuilderButton();
@ -38,7 +38,7 @@ acceptance("Poll Builder - polls are enabled", function (needs) {
);
});
test("staff - with insufficient trust level", async (assert) => {
test("staff - with insufficient trust level", async function (assert) {
updateCurrentUser({ moderator: true, trust_level: 0 });
await displayPollBuilderButton();
@ -49,7 +49,7 @@ acceptance("Poll Builder - polls are enabled", function (needs) {
);
});
test("poll preview", async (assert) => {
test("poll preview", async function (assert) {
await displayPollBuilderButton();
const popupMenu = selectKit(".toolbar-popup-menu-options");

View File

@ -8,7 +8,7 @@ acceptance("Rendering polls with pie charts", function (needs) {
poll_groupable_user_fields: "something",
});
test("Displays the pie chart", async (assert) => {
test("Displays the pie chart", async function (assert) {
await visit("/t/-/topic_with_pie_chart_poll");
const poll = queryAll(".poll")[0];

View File

@ -676,7 +676,7 @@ acceptance("Poll quote", function (needs) {
});
});
test("Quoted polls", async (assert) => {
test("Quoted polls", async function (assert) {
await visit("/t/-/topic_with_two_quoted_polls");
await click(".quote-controls");
assert.equal(queryAll(".poll").length, 2);

View File

@ -40,7 +40,7 @@ acceptance("Rendering polls with bar charts - desktop", function (needs) {
});
});
test("Polls", async (assert) => {
test("Polls", async function (assert) {
await visit("/t/-/15");
const polls = queryAll(".poll");
@ -60,7 +60,7 @@ acceptance("Rendering polls with bar charts - desktop", function (needs) {
);
});
test("Public poll", async (assert) => {
test("Public poll", async function (assert) {
await visit("/t/-/14");
const polls = queryAll(".poll");
@ -83,7 +83,7 @@ acceptance("Rendering polls with bar charts - desktop", function (needs) {
);
});
test("Public number poll", async (assert) => {
test("Public number poll", async function (assert) {
await visit("/t/-/13");
const polls = queryAll(".poll");

View File

@ -22,7 +22,7 @@ acceptance("Rendering polls with bar charts - mobile", function (needs) {
clearPopupMenuOptionsCallback();
});
test("Public number poll", async (assert) => {
test("Public number poll", async function (assert) {
await visit("/t/-/13");
const polls = queryAll(".poll");