2018-06-15 11:03:24 -04:00
|
|
|
import componentTest from "helpers/component-test";
|
|
|
|
moduleForComponent("value-list", { integration: true });
|
2015-06-09 12:19:41 -04:00
|
|
|
|
2018-08-03 16:41:37 -04:00
|
|
|
componentTest("adding a value", {
|
|
|
|
template: "{{value-list values=values}}",
|
|
|
|
|
2019-05-08 17:17:49 -04:00
|
|
|
skip: true,
|
2018-07-24 14:12:09 -04:00
|
|
|
async test(assert) {
|
2018-08-03 16:41:37 -04:00
|
|
|
this.set("values", "vinkas\nosama");
|
|
|
|
|
|
|
|
await selectKit().expand();
|
|
|
|
await selectKit().fillInFilter("eviltrout");
|
|
|
|
await selectKit().keyboard("enter");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(
|
2018-08-03 16:41:37 -04:00
|
|
|
find(".values .value").length === 3,
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
2019-05-27 04:15:39 -04:00
|
|
|
this.values,
|
2018-08-03 16:41:37 -04:00
|
|
|
"vinkas\nosama\neviltrout",
|
|
|
|
"it adds the value to the list of values"
|
2018-06-15 11:03:24 -04:00
|
|
|
);
|
2018-08-03 16:41:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest("removing a value", {
|
|
|
|
template: "{{value-list values=values}}",
|
|
|
|
|
|
|
|
async test(assert) {
|
|
|
|
this.set("values", "vinkas\nosama");
|
|
|
|
|
|
|
|
await click(".values .value[data-index='0'] .remove-value-btn");
|
2015-06-09 12:19:41 -04:00
|
|
|
|
2018-07-24 14:12:09 -04:00
|
|
|
assert.ok(
|
2018-08-03 16:41:37 -04:00
|
|
|
find(".values .value").length === 1,
|
|
|
|
"it removes the value from the list of values"
|
2018-07-24 14:12:09 -04:00
|
|
|
);
|
2015-06-09 12:19:41 -04:00
|
|
|
|
2019-05-27 04:15:39 -04:00
|
|
|
assert.equal(this.values, "osama", "it removes the expected value");
|
2018-08-03 16:41:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest("selecting a value", {
|
|
|
|
template: "{{value-list values=values choices=choices}}",
|
2015-06-09 12:19:41 -04:00
|
|
|
|
2018-08-03 16:41:37 -04:00
|
|
|
async test(assert) {
|
|
|
|
this.set("values", "vinkas\nosama");
|
|
|
|
this.set("choices", ["maja", "michael"]);
|
|
|
|
|
|
|
|
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 04:15:39 -04:00
|
|
|
this.values,
|
2018-08-03 16:41:37 -04:00
|
|
|
"vinkas\nosama\nmaja",
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
2015-07-14 13:56:59 -04:00
|
|
|
}
|
2015-06-09 12:19:41 -04:00
|
|
|
});
|
2015-07-28 12:29:40 -04:00
|
|
|
|
2018-08-03 16:41:37 -04:00
|
|
|
componentTest("array support", {
|
|
|
|
template: "{{value-list values=values inputType='array'}}",
|
2015-07-28 12:29:40 -04:00
|
|
|
|
2018-07-24 14:12:09 -04:00
|
|
|
async test(assert) {
|
2018-08-03 16:41:37 -04:00
|
|
|
this.set("values", ["vinkas", "osama"]);
|
|
|
|
|
|
|
|
await selectKit().expand();
|
|
|
|
await selectKit().fillInFilter("eviltrout");
|
|
|
|
await selectKit().keyboard("enter");
|
2015-07-28 12:29:40 -04:00
|
|
|
|
2018-08-03 16:41:37 -04:00
|
|
|
assert.ok(
|
|
|
|
find(".values .value").length === 3,
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
2015-07-28 12:29:40 -04:00
|
|
|
|
2018-08-03 16:41:37 -04:00
|
|
|
assert.deepEqual(
|
2019-05-27 04:15:39 -04:00
|
|
|
this.values,
|
2018-08-03 16:41:37 -04:00
|
|
|
["vinkas", "osama", "eviltrout"],
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
2015-07-28 12:29:40 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-08-03 16:41:37 -04:00
|
|
|
componentTest("delimiter support", {
|
|
|
|
template: "{{value-list values=values inputDelimiter='|'}}",
|
2015-07-28 12:29:40 -04:00
|
|
|
|
2019-05-08 17:17:49 -04:00
|
|
|
skip: true,
|
2018-07-24 14:12:09 -04:00
|
|
|
async test(assert) {
|
2018-08-03 16:41:37 -04:00
|
|
|
this.set("values", "vinkas|osama");
|
2015-07-28 12:29:40 -04:00
|
|
|
|
2018-08-03 16:41:37 -04:00
|
|
|
await selectKit().expand();
|
|
|
|
await selectKit().fillInFilter("eviltrout");
|
|
|
|
await selectKit().keyboard("enter");
|
2015-07-28 12:29:40 -04:00
|
|
|
|
2018-08-03 16:41:37 -04:00
|
|
|
assert.ok(
|
|
|
|
find(".values .value").length === 3,
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
2019-05-27 04:15:39 -04:00
|
|
|
this.values,
|
2018-08-03 16:41:37 -04:00
|
|
|
"vinkas|osama|eviltrout",
|
|
|
|
"it adds the value to the list of values"
|
|
|
|
);
|
2015-07-28 12:29:40 -04:00
|
|
|
}
|
|
|
|
});
|