diff --git a/README.md b/README.md index aa835369..fdd6e823 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ A datepicker Vue component. Compatible with Vue 2.x - [Demo](#demo) - [Install](#install) - [Usage](#usage) +- [Date Formatting](#date-formatting) - [Props](#available-props) - [Events](#events) - [Disabled dates](#disabled-dates) diff --git a/src/components/DateInput.vue b/src/components/DateInput.vue index 30291b72..b59ca61a 100644 --- a/src/components/DateInput.vue +++ b/src/components/DateInput.vue @@ -37,7 +37,7 @@ import DateUtils from '../utils/DateUtils' export default { props: { selectedDate: Date, - format: String, + format: [String, Function], translation: Object, inline: Boolean, id: String, diff --git a/test/unit/specs/DateInput/DateInput.spec.js b/test/unit/specs/DateInput/DateInput.spec.js index 26026103..7c56be69 100644 --- a/test/unit/specs/DateInput/DateInput.spec.js +++ b/test/unit/specs/DateInput/DateInput.spec.js @@ -59,4 +59,11 @@ describe('DateInput', () => { }) expect(wrapper.find('input').attributes().disabled).toBeDefined() }) + + it('accepts a function as a formatter', () => { + wrapper.setMethods({ + format: () => '!' + }) + expect(wrapper.find('input').element.value).toEqual('!') + }) })