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)
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
|
import { visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
acceptance("Badges", function (needs) {
|
|
needs.user();
|
|
|
|
test("Visit Badge Pages", async function (assert) {
|
|
await visit("/badges");
|
|
|
|
assert.ok($("body.badges-page").length, "has body class");
|
|
assert.ok(exists(".badge-groups .badge-card"), "has a list of badges");
|
|
|
|
await visit("/badges/9/autobiographer");
|
|
|
|
assert.ok(exists(".badge-card"), "has the badge in the listing");
|
|
assert.ok(exists(".user-info"), "has the list of users with that badge");
|
|
assert.ok(!exists(".badge-card:eq(0) script"));
|
|
});
|
|
|
|
test("shows correct badge titles to choose from", async function (assert) {
|
|
const availableBadgeTitles = selectKit(".select-kit");
|
|
await visit("/badges/50/custombadge");
|
|
await availableBadgeTitles.expand();
|
|
assert.ok(availableBadgeTitles.rowByIndex(1).name() === "CustomBadge");
|
|
});
|
|
});
|