Skip to content

Commit

Permalink
fix(dateinput): Display initial value of typeable calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
mst101 committed Nov 18, 2022
1 parent 0ce5cb4 commit cc0acdf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/DateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ export default {
}
})
},
selectedDate(selectedDate) {
if (this.typeable) {
this.typedDate = this.formatDate(selectedDate)
}
selectedDate: {
immediate: true,
handler(selectedDate) {
if (this.typeable) {
this.typedDate = this.formatDate(selectedDate)
}
},
},
},
mounted() {
Expand Down
23 changes: 23 additions & 0 deletions test/unit/specs/DateInput/typedDates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,29 @@ describe('Datepicker mounted', () => {
})
})

describe('Datepicker mounted with a default value', () => {
let wrapper

beforeEach(() => {
wrapper = mount(Datepicker, {
propsData: {
typeable: true,
value: new Date(new Date(2000, 0, 1).setHours(0, 0, 0, 0)),
},
})
})

afterEach(() => {
wrapper.destroy()
})

it('displays a date passed in as a default value', async () => {
const input = wrapper.find('input')

expect(input.element.value).toEqual('01 Jan 2000')
})
})

describe('Datepicker mounted with showCalendarOnFocus', () => {
let wrapper

Expand Down

0 comments on commit cc0acdf

Please sign in to comment.