Skip to content

Commit

Permalink
test: fix pikaday expect error
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Aug 26, 2016
1 parent 14c0602 commit 60a0868
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/fields/fieldPikaday.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
};
</script>

Expand Down
8 changes: 5 additions & 3 deletions test/unit/specs/fields/fieldPikaday.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe("fieldPikaday.vue", () => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
field.disabled = false;
done();
});
});
Expand All @@ -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();
});

Expand Down

0 comments on commit 60a0868

Please sign in to comment.