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

Commit

Permalink
unit(consultation): remove redundant test case
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Nov 15, 2022
1 parent 49588e0 commit 21f5463
Showing 1 changed file with 1 addition and 92 deletions.
93 changes: 1 addition & 92 deletions components/consultation/chat_window/rescheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,97 +7,7 @@ import convertTimeToMinutes from "$/time/convert_time_to_minutes"
import Component from "./rescheduler.vue"

describe("Component: consultation rescheduler", () => {
it("can update schedule day", async() => {
const schedules = {
"data": [
{
"attributes": {
"dayName": "monday",
"scheduleEnd": convertTimeToMinutes("09:00"),
"scheduleStart": convertTimeToMinutes("08:00")
},
"id": "1",
"type": "employee_schedule"
}
],
"meta": {
"count": 1
}
}
fetchMock.mockResponseOnce(
JSON.stringify(schedules),
{ "status": RequestEnvironment.status.OK }
)

fetchMock.mockResponseOnce("", { "status": RequestEnvironment.status.NO_CONTENT })

const wrapper = shallowMount(Component, {
"global": {
"provide": {
"pageContext": {
"pageProps": {
"consultation": {
"data": {
"scheduledStartAt": new Date("2022-10-09 07:00")
}
}
}
}
},
"stubs": {
"Overlay": false
}
},
"props": {
"isShown": true
}
})
// Load consultant schedules
await flushPromises()

// Change day
const scheduler = wrapper.findComponent({ "name": "Scheduler" })
const newDate = new Date("2022-10-10T08:00:00.000Z").toJSON()
await scheduler.vm.$emit("update:chosenDay", newDate)
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 [
[ unusedRequestForFetchingConsultantSchedule ],
[ requestForUpdatingConsultationSchedule ]
] = mockedFetch.mock.calls
expect(requestForUpdatingConsultationSchedule).toHaveProperty("method", "PATCH")
expect(await requestForUpdatingConsultationSchedule.json()).toStrictEqual({
"data": {
"attributes": {
"actionTaken": null,
"deletedAt": null,
"finishedAt": null,
"scheduledStartAt": newDate,
"startedAt": null
},
"relationships": {
"consultant": {},
"consultantRole": {
"data": {
"type": "role"
}
}
},
"type": "consultation"
},
"meta": {
"doesAllowConflicts": true
}
})
})

it("can update schedule time", async() => {
it("can update schedule of consultation", async() => {
const schedules = {
"data": [
{
Expand Down Expand Up @@ -155,7 +65,6 @@ describe("Component: consultation rescheduler", () => {
"chosenDate": newDate,
"chosenTime": newTime
})
await nextTick()

// Submit changes
const rescheduleBtn = wrapper.find(".reschedule-btn")
Expand Down

0 comments on commit 21f5463

Please sign in to comment.