Skip to content

Commit 140f691

Browse files
committed
test(unit): Move select day/month/year to mounted`
1 parent ee060f1 commit 140f691

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

test/unit/specs/Datepicker/Datepicker.spec.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -130,40 +130,6 @@ describe('Datepicker shallowMounted', () => {
130130
expect(wrapper.vm.isOpen).toEqual(false)
131131
})
132132

133-
it('can select a day', () => {
134-
const date = new Date(2016, 9, 1)
135-
136-
wrapper.vm.setView('day')
137-
wrapper.vm.handleSelect({ timestamp: date.valueOf() })
138-
139-
expect(wrapper.vm.selectedDate).toEqual(date)
140-
expect(wrapper.emitted('selected')).toBeTruthy()
141-
})
142-
143-
it('can select a month', () => {
144-
const date = new Date(2016, 9, 9)
145-
146-
wrapper.vm.setView('month')
147-
wrapper.vm.handleSelect({ timestamp: date.valueOf() })
148-
149-
expect(wrapper.emitted('changedMonth')[0][0].timestamp).toEqual(
150-
date.valueOf(),
151-
)
152-
expect(wrapper.vm.pageDate.getMonth()).toEqual(date.getMonth())
153-
})
154-
155-
it('can select a year', () => {
156-
const date = new Date(2018, 9, 9)
157-
158-
wrapper.vm.setView('year')
159-
wrapper.vm.handleSelect({ timestamp: date.valueOf() })
160-
161-
expect(wrapper.emitted('changedYear')[0][0].timestamp).toEqual(
162-
date.valueOf(),
163-
)
164-
expect(wrapper.vm.pageDate.getFullYear()).toEqual(date.getFullYear())
165-
})
166-
167133
it('watches modelValue', async () => {
168134
const spy = vi.spyOn(wrapper.vm, 'setValue')
169135

@@ -225,6 +191,40 @@ describe('Datepicker mounted', () => {
225191
wrapper.unmount()
226192
})
227193

194+
it('can select a day', () => {
195+
const date = new Date(2016, 9, 1)
196+
197+
wrapper.vm.setView('day')
198+
wrapper.vm.handleSelect({ timestamp: date.valueOf() })
199+
200+
expect(wrapper.vm.selectedDate).toEqual(date)
201+
expect(wrapper.emitted('selected')).toBeTruthy()
202+
})
203+
204+
it('can select a month', () => {
205+
const date = new Date(2016, 9, 9)
206+
207+
wrapper.vm.setView('month')
208+
wrapper.vm.handleSelect({ timestamp: date.valueOf() })
209+
210+
expect(wrapper.emitted('changedMonth')[0][0].timestamp).toEqual(
211+
date.valueOf(),
212+
)
213+
expect(wrapper.vm.pageDate.getMonth()).toEqual(date.getMonth())
214+
})
215+
216+
it('can select a year', () => {
217+
const date = new Date(2018, 9, 9)
218+
219+
wrapper.vm.setView('year')
220+
wrapper.vm.handleSelect({ timestamp: date.valueOf() })
221+
222+
expect(wrapper.emitted('changedYear')[0][0].timestamp).toEqual(
223+
date.valueOf(),
224+
)
225+
expect(wrapper.vm.pageDate.getFullYear()).toEqual(date.getFullYear())
226+
})
227+
228228
it('opens in `day` view', async () => {
229229
await wrapper.vm.open()
230230

0 commit comments

Comments
 (0)