2020-02-11 22:54:56 +08:00
|
|
|
import componentTest from "helpers/component-test";
|
2020-05-06 23:16:20 +08:00
|
|
|
import { testSelectKitModule } from "helpers/select-kit-helper";
|
2020-03-03 03:24:31 +08:00
|
|
|
import pretender from "helpers/create-pretender";
|
2020-02-11 22:54:56 +08:00
|
|
|
|
|
|
|
testSelectKitModule("user-chooser");
|
|
|
|
|
|
|
|
function template() {
|
|
|
|
return `{{user-chooser value=value}}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
componentTest("displays usernames", {
|
|
|
|
template: template(),
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.set("value", ["bob", "martin"]);
|
|
|
|
},
|
|
|
|
|
|
|
|
async test(assert) {
|
|
|
|
assert.equal(this.subject.header().name(), "bob,martin");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest("can remove a username", {
|
|
|
|
template: template(),
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.set("value", ["bob", "martin"]);
|
|
|
|
},
|
|
|
|
|
|
|
|
async test(assert) {
|
|
|
|
await this.subject.deselectItem("bob");
|
|
|
|
assert.equal(this.subject.header().name(), "martin");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest("can add a username", {
|
|
|
|
template: template(),
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.set("value", ["bob", "martin"]);
|
|
|
|
|
|
|
|
const response = object => {
|
|
|
|
return [200, { "Content-Type": "application/json" }, object];
|
|
|
|
};
|
|
|
|
|
2020-03-03 03:24:31 +08:00
|
|
|
pretender.get("/u/search/users", () => {
|
|
|
|
return response({ users: [{ username: "maja", name: "Maja" }] });
|
2020-02-11 22:54:56 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async test(assert) {
|
|
|
|
await this.subject.expand();
|
|
|
|
await this.subject.fillInFilter("maja");
|
|
|
|
await this.subject.keyboard("enter");
|
|
|
|
|
|
|
|
assert.equal(this.subject.header().name(), "bob,martin,maja");
|
|
|
|
}
|
|
|
|
});
|