2019-06-06 16:47:10 +08:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2015-07-15 01:56:59 +08:00
|
|
|
import componentTest from "helpers/component-test";
|
2015-06-10 00:19:41 +08:00
|
|
|
moduleForComponent("value-list", { integration: true });
|
|
|
|
|
2018-08-04 04:41:37 +08:00
|
|
|
componentTest("adding a value", {
|
|
|
|
template: "{{value-list values=values}}",
|
|
|
|
|
2019-05-09 05:17:49 +08:00
|
|
|
skip: true,
|
2020-02-03 21:22:14 +08:00
|
|
|
|
|
|
|
beforeEach() {
|
2018-08-04 04:41:37 +08:00
|
|
|
this.set("values", "vinkas\nosama");
|
2020-02-03 21:22:14 +08:00
|
|
|
},
|
2018-08-04 04:41:37 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
async test(assert) {
|
2018-08-04 04:41:37 +08:00
|
|
|
await selectKit().expand();
|
|
|
|
await selectKit().fillInFilter("eviltrout");
|
|
|
|
await selectKit().keyboard("enter");
|
|
|
|
|
2015-07-29 00:29:40 +08:00
|
|
|
assert.ok(
|
2018-08-04 04:41:37 +08:00
|
|
|
find(".values .value").length === 3,
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
2019-05-27 16:15:39 +08:00
|
|
|
this.values,
|
2018-08-04 04:41:37 +08:00
|
|
|
"vinkas\nosama\neviltrout",
|
|
|
|
"it adds the value to the list of values"
|
2015-07-29 00:29:40 +08:00
|
|
|
);
|
2018-08-04 04:41:37 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest("removing a value", {
|
|
|
|
template: "{{value-list values=values}}",
|
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
beforeEach() {
|
2018-08-04 04:41:37 +08:00
|
|
|
this.set("values", "vinkas\nosama");
|
2020-02-03 21:22:14 +08:00
|
|
|
},
|
2018-08-04 04:41:37 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
async test(assert) {
|
2018-08-04 04:41:37 +08:00
|
|
|
await click(".values .value[data-index='0'] .remove-value-btn");
|
2015-06-10 00:19:41 +08:00
|
|
|
|
2018-07-25 02:12:09 +08:00
|
|
|
assert.ok(
|
2018-08-04 04:41:37 +08:00
|
|
|
find(".values .value").length === 1,
|
|
|
|
"it removes the value from the list of values"
|
2018-07-25 02:12:09 +08:00
|
|
|
);
|
2015-06-10 00:19:41 +08:00
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
assert.equal(this.values, "osama", "it removes the expected value");
|
2020-02-15 00:21:06 +08:00
|
|
|
|
|
|
|
await selectKit().expand();
|
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
find(".select-kit-collection li.select-kit-row span.name")[0]
|
|
|
|
.innerText === "vinkas",
|
|
|
|
"it adds the removed value to choices"
|
|
|
|
);
|
2018-08-04 04:41:37 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest("selecting a value", {
|
|
|
|
template: "{{value-list values=values choices=choices}}",
|
2015-06-10 00:19:41 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
beforeEach() {
|
|
|
|
this.setProperties({
|
|
|
|
values: "vinkas\nosama",
|
|
|
|
choices: ["maja", "michael"]
|
|
|
|
});
|
|
|
|
},
|
2018-08-04 04:41:37 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
async test(assert) {
|
2018-08-04 04:41:37 +08:00
|
|
|
await selectKit().expand();
|
|
|
|
await selectKit().selectRowByValue("maja");
|
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
find(".values .value").length === 3,
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
2019-05-27 16:15:39 +08:00
|
|
|
this.values,
|
2018-08-04 04:41:37 +08:00
|
|
|
"vinkas\nosama\nmaja",
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
2015-07-15 01:56:59 +08:00
|
|
|
}
|
2015-06-10 00:19:41 +08:00
|
|
|
});
|
2015-07-29 00:29:40 +08:00
|
|
|
|
2018-08-04 04:41:37 +08:00
|
|
|
componentTest("array support", {
|
|
|
|
template: "{{value-list values=values inputType='array'}}",
|
2015-07-29 00:29:40 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
beforeEach() {
|
|
|
|
this.set("values", ["vinkas", "osama"]);
|
|
|
|
},
|
|
|
|
|
2018-07-25 02:12:09 +08:00
|
|
|
async test(assert) {
|
2018-08-04 04:41:37 +08:00
|
|
|
this.set("values", ["vinkas", "osama"]);
|
|
|
|
|
|
|
|
await selectKit().expand();
|
|
|
|
await selectKit().fillInFilter("eviltrout");
|
|
|
|
await selectKit().keyboard("enter");
|
2015-07-29 00:29:40 +08:00
|
|
|
|
2018-08-04 04:41:37 +08:00
|
|
|
assert.ok(
|
|
|
|
find(".values .value").length === 3,
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
2015-07-29 00:29:40 +08:00
|
|
|
|
2018-08-04 04:41:37 +08:00
|
|
|
assert.deepEqual(
|
2019-05-27 16:15:39 +08:00
|
|
|
this.values,
|
2018-08-04 04:41:37 +08:00
|
|
|
["vinkas", "osama", "eviltrout"],
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
2015-07-29 00:29:40 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-08-04 04:41:37 +08:00
|
|
|
componentTest("delimiter support", {
|
|
|
|
template: "{{value-list values=values inputDelimiter='|'}}",
|
2015-07-29 00:29:40 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
beforeEach() {
|
2018-08-04 04:41:37 +08:00
|
|
|
this.set("values", "vinkas|osama");
|
2020-02-03 21:22:14 +08:00
|
|
|
},
|
2015-07-29 00:29:40 +08:00
|
|
|
|
2020-02-03 21:22:14 +08:00
|
|
|
skip: true,
|
|
|
|
|
|
|
|
async test(assert) {
|
2018-08-04 04:41:37 +08:00
|
|
|
await selectKit().expand();
|
|
|
|
await selectKit().fillInFilter("eviltrout");
|
|
|
|
await selectKit().keyboard("enter");
|
2015-07-29 00:29:40 +08:00
|
|
|
|
2018-08-04 04:41:37 +08:00
|
|
|
assert.ok(
|
|
|
|
find(".values .value").length === 3,
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
2019-05-27 16:15:39 +08:00
|
|
|
this.values,
|
2018-08-04 04:41:37 +08:00
|
|
|
"vinkas|osama|eviltrout",
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
2015-07-29 00:29:40 +08:00
|
|
|
}
|
|
|
|
});
|