mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 18:25:12 +08:00
c99ecba68f
- reduces the API to 3 actions for now: appendContent/prependContent/onChange - well tested - removes all previous APIS which were only half supported or too dangerous as they could collide with other plugins or core behaviors - this plugins also puts every sk test helpers in one file
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
import componentTest from "helpers/component-test";
|
|
import { testSelectKitModule } from "helpers/select-kit-helper";
|
|
import pretender from "helpers/create-pretender";
|
|
|
|
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];
|
|
};
|
|
|
|
pretender.get("/u/search/users", () => {
|
|
return response({ users: [{ username: "maja", name: "Maja" }] });
|
|
});
|
|
},
|
|
|
|
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");
|
|
}
|
|
});
|