We used many global functions to handle tests when they should be imported like other libraries in our application. This also gets us closer to the way Ember CLI prefers our tests to be laid out.
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { moduleForComponent } from "ember-qunit";
|
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
|
import componentTest from "discourse/tests/helpers/component-test";
|
|
import EmberObject from "@ember/object";
|
|
import pretender from "discourse/tests/helpers/create-pretender";
|
|
|
|
moduleForComponent("badge-title", { integration: true });
|
|
|
|
componentTest("badge title", {
|
|
template:
|
|
"{{badge-title selectableUserBadges=selectableUserBadges user=user}}",
|
|
|
|
beforeEach() {
|
|
this.set("subject", selectKit());
|
|
this.set("selectableUserBadges", [
|
|
EmberObject.create({
|
|
id: 0,
|
|
badge: { name: "(none)" },
|
|
}),
|
|
EmberObject.create({
|
|
id: 42,
|
|
badge_id: 102,
|
|
badge: { name: "Test" },
|
|
}),
|
|
]);
|
|
},
|
|
|
|
async test(assert) {
|
|
pretender.put("/u/eviltrout/preferences/badge_title", () => [
|
|
200,
|
|
{ "Content-Type": "application/json" },
|
|
{},
|
|
]);
|
|
await this.subject.expand();
|
|
await this.subject.selectRowByValue(42);
|
|
await click(".btn");
|
|
assert.equal(this.currentUser.title, "Test");
|
|
},
|
|
});
|