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 request properties
Browse files Browse the repository at this point in the history
Co-authored-by: Kenneth Trecy Tobias <19201.tobias.kennethtrecy.c@gmail.com>
  • Loading branch information
lemredd and KennethTrecy committed Oct 11, 2022
1 parent 24ffd3e commit bc2acd8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions components/consultation/chat_window.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { shallowMount, flushPromises } from "@vue/test-utils"
import type { DeserializedConsultationResource } from "$/types/documents/consultation"
import type { DeserializedChatMessageListDocument } from "$/types/documents/chat_message"

import { JSON_API_MEDIA_TYPE } from "$/types/server"

import { CONSULTATION_LINK } from "$/constants/template_links"

import specializePath from "$/helpers/specialize_path"
Expand Down Expand Up @@ -389,8 +391,30 @@ describe("Component: consultation/chat_window", () => {
"consultation": secondUpdatedFakeConsultation
})
await flushPromises()

const events = wrapper.emitted("updatedConsultationAttributes")
expect(events).toHaveLength(2)
const castFetch = fetch as jest.Mock<any, any>
const [ [ firstRequest ], [ secondRequest ] ] = castFetch.mock.calls
expect(firstRequest).toHaveProperty("method", "PATCH")
expect(firstRequest).toHaveProperty(
"url",
specializePath(CONSULTATION_LINK.bound, { id })
)
expect(firstRequest.headers.get("Content-Type")).toBe(JSON_API_MEDIA_TYPE)
expect(firstRequest.headers.get("Accept")).toBe(JSON_API_MEDIA_TYPE)

expect(secondRequest).toHaveProperty("method", "PATCH")
expect(secondRequest).toHaveProperty(
"url",
specializePath(CONSULTATION_LINK.bound, { id })
)
expect(secondRequest.headers.get("Content-Type")).toBe(JSON_API_MEDIA_TYPE)
expect(secondRequest.headers.get("Accept")).toBe(JSON_API_MEDIA_TYPE)

const body = await secondRequest.json()
expect(body).toHaveProperty("data.relationships.consultant.data.id")
expect(body).toHaveProperty("meta.doesAllowConflicts")
})
})
})

0 comments on commit bc2acd8

Please sign in to comment.