2020-04-23 04:17:53 +08:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2019-07-18 23:29:41 +08:00
|
|
|
import componentTest from "helpers/component-test";
|
|
|
|
|
2020-04-23 04:17:53 +08:00
|
|
|
moduleForComponent("time-input", {
|
|
|
|
integration: true,
|
2019-07-18 23:29:41 +08:00
|
|
|
|
2020-04-23 04:17:53 +08:00
|
|
|
beforeEach() {
|
|
|
|
this.set("subject", selectKit());
|
|
|
|
}
|
|
|
|
});
|
2019-07-18 23:29:41 +08:00
|
|
|
|
|
|
|
function setTime(time) {
|
|
|
|
this.setProperties(time);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentTest("default", {
|
|
|
|
template: `{{time-input hours=hours minutes=minutes}}`,
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.setProperties({ hours: "14", minutes: "58" });
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2020-04-23 04:17:53 +08:00
|
|
|
assert.equal(this.subject.header().name(), "14:58");
|
2019-07-18 23:29:41 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest("prevents mutations", {
|
|
|
|
template: `{{time-input hours=hours minutes=minutes}}`,
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.setProperties({ hours: "14", minutes: "58" });
|
|
|
|
},
|
|
|
|
|
|
|
|
async test(assert) {
|
2020-04-23 04:17:53 +08:00
|
|
|
await this.subject.expand();
|
|
|
|
await this.subject.selectRowByIndex(3);
|
|
|
|
assert.equal(this.subject.header().name(), "14:58");
|
2019-07-18 23:29:41 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
componentTest("allows mutations through actions", {
|
|
|
|
template: `{{time-input hours=hours minutes=minutes onChange=onChange}}`,
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.setProperties({ hours: "14", minutes: "58" });
|
|
|
|
this.set("onChange", setTime);
|
|
|
|
},
|
|
|
|
|
|
|
|
async test(assert) {
|
2020-04-23 04:17:53 +08:00
|
|
|
await this.subject.expand();
|
|
|
|
await this.subject.selectRowByIndex(3);
|
|
|
|
assert.equal(this.subject.header().name(), "00:45");
|
2019-07-18 23:29:41 +08:00
|
|
|
}
|
|
|
|
});
|