2019-11-30 05:12:05 +08:00
|
|
|
import componentTest from "helpers/component-test";
|
|
|
|
|
|
|
|
moduleForComponent("user-selector", { integration: true });
|
|
|
|
|
2020-01-11 01:02:43 +08:00
|
|
|
function paste(element, text) {
|
|
|
|
let e = new Event("paste");
|
|
|
|
e.clipboardData = { getData: () => text };
|
|
|
|
element.dispatchEvent(e);
|
2020-01-11 01:27:41 +08:00
|
|
|
}
|
2020-01-11 01:02:43 +08:00
|
|
|
|
2019-11-30 05:12:05 +08:00
|
|
|
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];
|
|
|
|
|
|
|
|
assert.equal(this.get("usernames"), "evil,trout");
|
2020-01-11 01:02:43 +08:00
|
|
|
paste(element, "zip,zap,zoom");
|
2019-11-30 05:12:05 +08:00
|
|
|
assert.equal(this.get("usernames"), "evil,trout,zip,zap,zoom");
|
2020-01-11 01:02:43 +08:00
|
|
|
paste(element, "evil,abc,abc,abc");
|
2019-11-30 05:12:05 +08:00
|
|
|
assert.equal(this.get("usernames"), "evil,trout,zip,zap,zoom,abc");
|
|
|
|
|
|
|
|
this.set("usernames", "");
|
2020-01-11 01:02:43 +08:00
|
|
|
paste(element, "names with spaces");
|
2019-11-30 05:12:05 +08:00
|
|
|
assert.equal(this.get("usernames"), "names,with,spaces");
|
|
|
|
|
|
|
|
this.set("usernames", null);
|
2020-01-11 01:02:43 +08:00
|
|
|
paste(element, "@eviltrout,@codinghorror sam");
|
2019-11-30 05:12:05 +08:00
|
|
|
assert.equal(this.get("usernames"), "eviltrout,codinghorror,sam");
|
|
|
|
|
|
|
|
this.set("usernames", null);
|
2020-01-11 01:02:43 +08:00
|
|
|
paste(element, "eviltrout\nsam\ncodinghorror");
|
2019-11-30 05:12:05 +08:00
|
|
|
assert.equal(this.get("usernames"), "eviltrout,sam,codinghorror");
|
|
|
|
}
|
|
|
|
});
|
2020-01-11 01:02:43 +08:00
|
|
|
|
|
|
|
componentTest("excluding usernames", {
|
|
|
|
template: `{{user-selector usernames=usernames excludedUsernames=excludedUsernames class="test-selector"}}`,
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.set("usernames", "mark");
|
|
|
|
this.set("excludedUsernames", ["jeff", "sam", "robin"]);
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
let element = find(".test-selector")[0];
|
|
|
|
paste(element, "roman,penar,jeff,robin");
|
|
|
|
assert.equal(this.get("usernames"), "mark,roman,penar");
|
|
|
|
}
|
|
|
|
});
|