Skip to content

Commit 60a0868

Browse files
committed
test: fix pikaday expect error
1 parent 14c0602 commit 60a0868

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/fields/fieldPikaday.vue

+7-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
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")
5454
reposition: true, // can be set to false to not reposition datepicker within the viewport, forcing it to take the configured `position` (default: true)
5555
// container: , // DOM node to render calendar into, see [container example][] (default: undefined)
56-
// format: , // the default output format for `.toString()` and `field` value (requires [Moment.js][moment] for custom formatting)
56+
format: inputFormat, // the default output format for `.toString()` and `field` value (requires [Moment.js][moment] for custom formatting)
5757
// formatStrict: , // the default flag for moment"s strict date parsing (requires [Moment.js][moment] for custom formatting)
5858
// defaultDate: , // the initial date to view when first opened
5959
// setDefaultDate: , // make the `defaultDate` the initial selected value
@@ -88,7 +88,12 @@
8888
console.warn("Pikaday is missing. Please download from https://github.com/dbushell/Pikaday/ and load the script and CSS in the HTML head section!");
8989
}
9090
91-
}
91+
},
92+
93+
beforeDestroy() {
94+
if (this.picker)
95+
this.picker.destroy();
96+
}
9297
};
9398
</script>
9499

test/unit/specs/fields/fieldPikaday.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe("fieldPikaday.vue", () => {
5050
field.disabled = true;
5151
vm.$nextTick( () => {
5252
expect(input.disabled).to.be.true;
53+
field.disabled = false;
5354
done();
5455
});
5556
});
@@ -64,11 +65,12 @@ describe("fieldPikaday.vue", () => {
6465
});
6566

6667
it("model value should be the input value if changed", (done) => {
67-
input.value = moment(1420153200000).format("YYYY-MM-DD");
68-
trigger(input, "input");
68+
let day = moment(1420070400000).format("YYYY-MM-DD");
69+
field.picker.setDate(day);
6970

7071
vm.$nextTick( () => {
71-
expect(model.event).to.be.equal(1420153200000);
72+
expect(input.value).to.be.equal(day);
73+
expect(moment(model.event).format("YYYY-MM-DD")).to.be.equal(day);
7274
done();
7375
});
7476

0 commit comments

Comments
 (0)