FEATURE: pass in excluded usernames to user-selector (#8695)

This commit is contained in:
Mark VanLandingham
2020-01-10 09:02:43 -08:00
committed by GitHub
parent 5a70f50032
commit 5898afaa73
2 changed files with 39 additions and 18 deletions

View File

@ -2,6 +2,12 @@ import componentTest from "helpers/component-test";
moduleForComponent("user-selector", { integration: true });
function paste(element, text) {
let e = new Event("paste");
e.clipboardData = { getData: () => text };
element.dispatchEvent(e);
};
componentTest("pasting a list of usernames", {
template: `{{user-selector usernames=usernames class="test-selector"}}`,
@ -11,28 +17,38 @@ componentTest("pasting a list of usernames", {
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");
paste(element, "zip,zap,zoom");
assert.equal(this.get("usernames"), "evil,trout,zip,zap,zoom");
paste("evil,abc,abc,abc");
paste(element, "evil,abc,abc,abc");
assert.equal(this.get("usernames"), "evil,trout,zip,zap,zoom,abc");
this.set("usernames", "");
paste("names with spaces");
paste(element, "names with spaces");
assert.equal(this.get("usernames"), "names,with,spaces");
this.set("usernames", null);
paste("@eviltrout,@codinghorror sam");
paste(element, "@eviltrout,@codinghorror sam");
assert.equal(this.get("usernames"), "eviltrout,codinghorror,sam");
this.set("usernames", null);
paste("eviltrout\nsam\ncodinghorror");
paste(element, "eviltrout\nsam\ncodinghorror");
assert.equal(this.get("usernames"), "eviltrout,sam,codinghorror");
}
});
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");
}
});