mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 18:35:23 +08:00
176aa0ac7d
* DEV: Remove server global test variable * Delete yarn-error.log * prettier and some eslint fixes * add global server variable back for plugins * rename imported server to pretender * prettier * support plugin server. usage * Export pretender as named * Prettier * change default pretender export * fix bad import * Use pretender() and original default export * export new Pretender as default * fix accidental change * WIP testing * add pretend handlers in correct location * move more stuff into the correct pretender * Consolidated more pretenders * comment out another bad test * fix user acceptance tests * commented out bad test * fixed another composer server stub * fix more tests * fixed tag test pretender * Fix admin email test * removed another draft handler * add back test * fix and uncomment another test * remove test that is not useful * remove commented out lines * reapply handlers between every test * no need to re-stub requests now :) * cleanup from review * more cleanup
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
import componentTest from "helpers/component-test";
|
|
import { testSelectKitModule } from "./select-kit-test-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");
|
|
}
|
|
});
|