Skip to content

Commit

Permalink
DEV: attempts to make date-time-input-range test more reliable (#8126)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaffeux committed Oct 2, 2019
1 parent 45513fb commit 0b93f12
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions test/javascripts/components/date-time-input-range-test.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ async function pika(year, month, day) {
const DEFAULT_DATE_TIME = new Date(2019, 0, 29, 14, 45);

componentTest("default", {
template: `{{date-time-input-range from=date to=to}}`,
template: `{{date-time-input-range from=from to=to}}`,

beforeEach() {
this.setProperties({ date: DEFAULT_DATE_TIME, to: null });
this.setProperties({ from: DEFAULT_DATE_TIME, to: null });
},

test(assert) {
Expand All @@ -63,7 +63,7 @@ componentTest("can switch panels", {
assert.ok(exists(".panel.from.visible"));
assert.notOk(exists(".panel.to.visible"));

await click(".panels .to-panel");
await click(".panels button.to-panel");

assert.ok(exists(".panel.to.visible"));
assert.notOk(exists(".panel.from.visible"));
Expand All @@ -82,22 +82,24 @@ componentTest("prevents toDate to be before fromDate", {
},

async test(assert) {
assert.notOk(exists(".error"));
assert.notOk(exists(".error"), "it begins with no error");

await click(".panels button.to-panel");
await click(toDateInput());
await pika(2019, 0, 1);

assert.ok(exists(".error"));
assert.ok(
this.to.getTime() === DEFAULT_DATE_TIME.getTime(),
"it didnt trigger a mutation"
);
assert.ok(exists(".error"), "it shows an error");
assert.deepEqual(this.to, DEFAULT_DATE_TIME, "it didnt trigger a mutation");

await click("button.to-panel");
await click(".panels button.to-panel");
await click(toDateInput());
await pika(2019, 0, 30);

assert.notOk(exists(".error"));
assert.ok(this.to.getTime() === new Date(2019, 0, 30, 14, 45).getTime());
assert.notOk(exists(".error"), "it removes the error");
assert.deepEqual(
this.to,
new Date(2019, 0, 30, 14, 45),
"it has changed the date"
);
}
});

0 comments on commit 0b93f12

Please sign in to comment.