discourse/test/javascripts/components/user-selector-test.js.es6
Robin Ward 5df719a3c2 FEATURE: Support pasting a list of usernames into a PM
This allows you to paste multiple usernames into a PM's recipient list
at once. It supports usernames separated by spaces, commas, and new lines.
2019-12-02 11:28:09 -05:00

39 lines
1.2 KiB
JavaScript

import componentTest from "helpers/component-test";
moduleForComponent("user-selector", { integration: true });
componentTest("pasting a list of usernames", {
template: `{{user-selector usernames=usernames class="test-selector"}}`,
beforeEach() {
this.set("usernames", "evil,trout");
},
test(assert) {
let element = find(".test-selector")[0];
let paste = text => {
let e = new Event("paste");
e.clipboardData = { getData: () => text };
element.dispatchEvent(e);
};
assert.equal(this.get("usernames"), "evil,trout");
paste("zip,zap,zoom");
assert.equal(this.get("usernames"), "evil,trout,zip,zap,zoom");
paste("evil,abc,abc,abc");
assert.equal(this.get("usernames"), "evil,trout,zip,zap,zoom,abc");
this.set("usernames", "");
paste("names with spaces");
assert.equal(this.get("usernames"), "names,with,spaces");
this.set("usernames", null);
paste("@eviltrout,@codinghorror sam");
assert.equal(this.get("usernames"), "eviltrout,codinghorror,sam");
this.set("usernames", null);
paste("eviltrout\nsam\ncodinghorror");
assert.equal(this.get("usernames"), "eviltrout,sam,codinghorror");
}
});