From 60a0868b6fb43f0db62d062e4b5815524fa288cf Mon Sep 17 00:00:00 2001 From: Icebob Date: Fri, 26 Aug 2016 09:57:08 +0200 Subject: [PATCH] test: fix pikaday expect error --- src/fields/fieldPikaday.vue | 9 +++++++-- test/unit/specs/fields/fieldPikaday.spec.js | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/fields/fieldPikaday.vue b/src/fields/fieldPikaday.vue index ab8e1d41..d1154594 100644 --- a/src/fields/fieldPikaday.vue +++ b/src/fields/fieldPikaday.vue @@ -53,7 +53,7 @@ position: "bottom left", // preferred position of the datepicker relative to the form field, e.g.: `top right`, `bottom right` **Note:** automatic adjustment may occur to avoid datepicker from being displayed outside the viewport, see [positions example][] (default to "bottom left") reposition: true, // can be set to false to not reposition datepicker within the viewport, forcing it to take the configured `position` (default: true) // container: , // DOM node to render calendar into, see [container example][] (default: undefined) - // format: , // the default output format for `.toString()` and `field` value (requires [Moment.js][moment] for custom formatting) + format: inputFormat, // the default output format for `.toString()` and `field` value (requires [Moment.js][moment] for custom formatting) // formatStrict: , // the default flag for moment"s strict date parsing (requires [Moment.js][moment] for custom formatting) // defaultDate: , // the initial date to view when first opened // setDefaultDate: , // make the `defaultDate` the initial selected value @@ -88,7 +88,12 @@ console.warn("Pikaday is missing. Please download from https://github.com/dbushell/Pikaday/ and load the script and CSS in the HTML head section!"); } - } + }, + + beforeDestroy() { + if (this.picker) + this.picker.destroy(); + } }; diff --git a/test/unit/specs/fields/fieldPikaday.spec.js b/test/unit/specs/fields/fieldPikaday.spec.js index 7b91e372..d0a147c1 100644 --- a/test/unit/specs/fields/fieldPikaday.spec.js +++ b/test/unit/specs/fields/fieldPikaday.spec.js @@ -50,6 +50,7 @@ describe("fieldPikaday.vue", () => { field.disabled = true; vm.$nextTick( () => { expect(input.disabled).to.be.true; + field.disabled = false; done(); }); }); @@ -64,11 +65,12 @@ describe("fieldPikaday.vue", () => { }); it("model value should be the input value if changed", (done) => { - input.value = moment(1420153200000).format("YYYY-MM-DD"); - trigger(input, "input"); + let day = moment(1420070400000).format("YYYY-MM-DD"); + field.picker.setDate(day); vm.$nextTick( () => { - expect(model.event).to.be.equal(1420153200000); + expect(input.value).to.be.equal(day); + expect(moment(model.event).format("YYYY-MM-DD")).to.be.equal(day); done(); });