Skip to content

Commit

Permalink
Workaround and parsing isoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
zemogle committed Nov 19, 2024
1 parent 60129a5 commit e9b94b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/components/Scheduling/Calendar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { ref, watch, defineEmits, onMounted } from 'vue'
import { fetchSemesterData, currentSemesterEnd } from '../../utils/calendarUtils'
import { fetchSemesterData, currentSemesterEnd, parseISOString } from '../../utils/calendarUtils'
const emits = defineEmits(['updateDateRange'])
Expand All @@ -25,9 +25,13 @@ onMounted(async () => {
mode="date"
is-range
:min-date="today"
:max-date="currentSemesterEnd"
:max-date="parseISOString(currentSemesterEnd)"
placeholder="Select Dates"

Check failure on line 29 in src/components/Scheduling/Calendar.vue

View workflow job for this annotation

GitHub Actions / test

src/tests/integration/components/calendar.test.js > Calendar.vue > calls fetchSemesterData on mount

Error: [vitest] No "parseISOString" export is defined on the "../../../utils/calendarUtils" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("../../../utils/calendarUtils"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ Proxy.get parseISOString src/components/Scheduling/Calendar.vue:29:367 ❯ Object.get node_modules/@vue/reactivity/dist/reactivity.cjs.js:1521:78 ❯ Proxy._sfc_render src/components/Scheduling/Calendar.vue:28:20 ❯ renderComponentRoot node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6385:16 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5207:46 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5342:5

Check failure on line 29 in src/components/Scheduling/Calendar.vue

View workflow job for this annotation

GitHub Actions / test

src/tests/integration/components/calendar.test.js > Calendar.vue > passes the correct max-date to VDatePicker

Error: [vitest] No "parseISOString" export is defined on the "../../../utils/calendarUtils" mock. Did you forget to return it from "vi.mock"? If you need to partially mock a module, you can use "importOriginal" helper inside: vi.mock(import("../../../utils/calendarUtils"), async (importOriginal) => { const actual = await importOriginal() return { ...actual, // your mocked methods } }) ❯ Proxy.get parseISOString src/components/Scheduling/Calendar.vue:29:367 ❯ Object.get node_modules/@vue/reactivity/dist/reactivity.cjs.js:1521:78 ❯ Proxy._sfc_render src/components/Scheduling/Calendar.vue:28:20 ❯ renderComponentRoot node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6385:16 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5207:46 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5342:5
is-required
/>
@dayclick="
(_, event) => {
event.target.blur();
}
" />
</div>
</template>
8 changes: 7 additions & 1 deletion src/utils/calendarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { useConfigurationStore } from '../stores/configuration.js'
let currentSemesterStart = null
let currentSemesterEnd = null

function parseISOString (s) {
if (s === null) return null
const b = s.split(/\D+/)
return new Date(Date.UTC(b[0], --b[1], b[2], b[3], b[4], b[5], b[6]))
}

const getStartAndEndDatesOfCurrentSemester = (semesters) => {
const today = new Date()
const currentSemester = semesters.find(semester => {
Expand All @@ -30,4 +36,4 @@ const fetchSemesterData = async () => {
})
}

export { currentSemesterStart, currentSemesterEnd, fetchSemesterData }
export { currentSemesterStart, currentSemesterEnd, fetchSemesterData, parseISOString }

0 comments on commit e9b94b6

Please sign in to comment.