From ceb8c42e30bb861d204c92abb26a5ecb9548316a Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Mon, 17 Jan 2022 21:53:03 -0500 Subject: [PATCH] new implementation of PikadayInput has all tests passing --- jsconfig.json | 5 ++ src/components/pikaday-input2.hbs | 1 + src/components/pikaday-input2.js | 10 ++-- src/modifiers/pikaday.js | 53 ++++++++++++++++--- .../components/pikaday-input2-test.js | 3 +- 5 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..504cd64 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "experimentalDecorators": true + } +} diff --git a/src/components/pikaday-input2.hbs b/src/components/pikaday-input2.hbs index b21fb7c..1cd74e0 100644 --- a/src/components/pikaday-input2.hbs +++ b/src/components/pikaday-input2.hbs @@ -1,5 +1,6 @@ maxDate) { + value = maxDate; + valueAltered = true; + } + + this.#pikaday.setDate(value, !valueAltered); + this.#pikaday.config(this.pikadayOptions); } willDestroy() { @@ -38,3 +70,12 @@ export default class PikadayModifier extends Modifier { } } } + +// apparently Pikaday mutates Dates that you pass it for minDate and maxDate. +function copyDate(date) { + if (date) { + return new Date(date.getTime()); + } else { + return date; + } +} diff --git a/test-app/tests/integration/components/pikaday-input2-test.js b/test-app/tests/integration/components/pikaday-input2-test.js index 7e17395..82d284c 100644 --- a/test-app/tests/integration/components/pikaday-input2-test.js +++ b/test-app/tests/integration/components/pikaday-input2-test.js @@ -19,7 +19,7 @@ const getDisabledDayCB = (weekendDay) => (e) => { return attr ? attr.value == weekendDay : false; }; -module.skip('Integration | Component | pikaday-input2', function (hooks) { +module('Integration | Component | pikaday-input2', function (hooks) { setupRenderingTest(hooks); test('it is an input tag', async function (assert) { @@ -666,6 +666,7 @@ module.skip('Integration | Component | pikaday-input2', function (hooks) { this.set('minDate', today); this.set('maxDate', tomorrow); + await settled(); assert.equal( today.toISOString(),