Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
unit(consultation): ensure new time is passed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Nov 15, 2022
1 parent 747548f commit 20f1621
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
15 changes: 6 additions & 9 deletions components/consultation/chat_window/rescheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ describe("Component: consultation rescheduler", () => {
await rescheduleBtn.trigger("click")
await flushPromises()

const mockedFetch = fetch as jest.Mock<any, any>
const castFetch = fetch as jest.Mock<any, any>
const [
[ unusedRequestForFetchingConsultantSchedule ],
[ requestForUpdatingConsultationSchedule ]
] = mockedFetch.mock.calls
] = castFetch.mock.calls
expect(requestForUpdatingConsultationSchedule).toHaveProperty("method", "PATCH")
expect(await requestForUpdatingConsultationSchedule.json()).toStrictEqual({
"data": {
Expand Down Expand Up @@ -148,25 +148,22 @@ describe("Component: consultation rescheduler", () => {
// Change day
const scheduler = wrapper.findComponent({ "name": "Scheduler" })
const newDate = new Date("2022-10-10T00:00:00.000Z").toJSON()
const newTime = convertTimeToMinutes("08:00")
const newTime = String(convertTimeToMinutes("08:00"))
await scheduler.vm.$emit("update:chosenDay", newDate)
await scheduler.vm.$emit("update:chosenTime", newTime)
await wrapper.setProps({
"chosenDate": newDate,
"chosenTime": newTime
})
await nextTick()

// Submit changes
const rescheduleBtn = wrapper.find(".reschedule-btn")
await rescheduleBtn.trigger("click")
await flushPromises()

const mockedFetch = fetch as jest.Mock<any, any>
const castFetch = fetch as jest.Mock<any, any>
expect(castFetch).toHaveBeenCalledTimes(2)
const [
[ unusedRequestForFetchingConsultantSchedule ],
[ requestForUpdatingConsultationSchedule ]
] = mockedFetch.mock.calls
] = castFetch.mock.calls
expect(requestForUpdatingConsultationSchedule).toHaveProperty("method", "PATCH")
expect(await requestForUpdatingConsultationSchedule.json()).toStrictEqual({
"data": {
Expand Down
12 changes: 6 additions & 6 deletions components/consultation/chat_window/rescheduler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ import ReceivedSuccessMessages from "@/helpers/message_handlers/received_success
const pageContext = inject("pageContext") as PageContext<"deserialized", "consultation">
const { pageProps } = pageContext
type DefinedProps = {
defineProps<{
isShown: boolean
}
type CustomEvents = {
}>()
interface CustomEvents {
(event: "hide"): void
(event: "rescheduleConsultation"): void
}
defineProps<DefinedProps>()
const emit = defineEmits<CustomEvents>()
function hideOverlay() {
Expand All @@ -70,8 +70,8 @@ function hideOverlay() {
const { consultation } = pageProps
const employeeScheduleFetcher = new EmployeeScheduleFetcher()
const chosenDay = ref("")
const chosenTime = ref("")
const chosenDay = ref<string>("")
const chosenTime = ref<string>("")
const scheduledStartAt = computed(() => {
const chosenDate = new Date(chosenDay.value)
Expand Down

0 comments on commit 20f1621

Please sign in to comment.