This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.js
Robin Ward 23f24bfb51 REFACTOR: Move javascript tests inside discourse app
This is where they should be as far as ember is concerned. Note this is
a huge commit and we should be really careful everything continues to
work properly.
2020-10-02 11:29:36 -04:00

39 lines
1.0 KiB
JavaScript

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");
},
});