Skip to content

Commit

Permalink
test: allow datepicker test to pass in December
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohan Bansal committed Dec 17, 2024
1 parent afa8056 commit 0484e4f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
66 changes: 34 additions & 32 deletions aform/src/components/form/ADatePicker.vue
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
<template>
<div class="adatepicker" tabindex="0" ref="datepicker">
<table>
<tr>
<td id="previous-month-btn" @click="previousMonth" :tabindex="-1">&lt;</td>
<th colspan="5" :tabindex="-1">{{ monthAndYear }}</th>
<td id="next-month-btn" @click="nextMonth" :tabindex="-1">&gt;</td>
</tr>
<tr class="days-header">
<td>M</td>
<td>T</td>
<td>W</td>
<td>T</td>
<td>F</td>
<td>S</td>
<td>S</td>
</tr>
<tr v-for="rowNo in numberOfRows" :key="rowNo">
<!-- the 'ref' key is currently only used for test references -->
<td
v-for="colNo in numberOfColumns"
ref="celldate"
:key="getCurrentCell(rowNo, colNo)"
:contenteditable="false"
:spellcheck="false"
:tabindex="0"
@click.prevent.stop="selectDate(getCurrentCell(rowNo, colNo))"
@keydown.enter="selectDate(getCurrentCell(rowNo, colNo))"
:class="{
todaysDate: isTodaysDate(getCurrentDate(rowNo, colNo)),
selectedDate: isSelectedDate(getCurrentDate(rowNo, colNo)),
}">
{{ new Date(getCurrentDate(rowNo, colNo)).getDate() }}
</td>
</tr>
<tbody>
<tr>
<td id="previous-month-btn" @click="previousMonth" :tabindex="-1">&lt;</td>
<th colspan="5" :tabindex="-1">{{ monthAndYear }}</th>
<td id="next-month-btn" @click="nextMonth" :tabindex="-1">&gt;</td>
</tr>
<tr class="days-header">
<td>M</td>
<td>T</td>
<td>W</td>
<td>T</td>
<td>F</td>
<td>S</td>
<td>S</td>
</tr>
<tr v-for="rowNo in numberOfRows" :key="rowNo">
<!-- the 'ref' key is currently only used for test references -->
<td
v-for="colNo in numberOfColumns"
ref="celldate"
:key="getCurrentCell(rowNo, colNo)"
:contenteditable="false"
:spellcheck="false"
:tabindex="0"
@click.prevent.stop="selectDate(getCurrentCell(rowNo, colNo))"
@keydown.enter="selectDate(getCurrentCell(rowNo, colNo))"
:class="{
todaysDate: isTodaysDate(getCurrentDate(rowNo, colNo)),
selectedDate: isSelectedDate(getCurrentDate(rowNo, colNo)),
}">
{{ new Date(getCurrentDate(rowNo, colNo)).getDate() }}
</td>
</tr>
</tbody>
</table>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion aform/tests/datepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('datepicker component', () => {

const $prevMonthBtn = wrapper.find('#next-month-btn')
await $prevMonthBtn.trigger('click')
expect(wrapper.vm.currentMonth).toBe(new Date().getMonth() + 1)
expect(wrapper.vm.currentMonth).toBe((new Date().getMonth() + 1) % 12)
})

it('select next year', async () => {
Expand Down

0 comments on commit 0484e4f

Please sign in to comment.