Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@liannoi
Created October 27, 2022 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liannoi/1f778f255252101e5c278abc9bb80bba to your computer and use it in GitHub Desktop.
Save liannoi/1f778f255252101e5c278abc9bb80bba to your computer and use it in GitHub Desktop.
Feature Request for Pact Foundation (pact-js)
test("should throw an error for invalid id", async () => {
const badRequestData = {
error: {
code: "validationError",
message: "Validation error(s) has occurred",
details: [],
},
};
const badRequestResponse = somethingLike({
error: {
code: like(badRequestData.error.code),
message: like(badRequestData.error.message),
details: like(badRequestData.error.details),
},
});
const status = 400;
await provider.addInteraction({
state: "...",
uponReceiving: "a bad post content request",
withRequest: { method, headers, path, body: /* Some changes for that */ new ArrayBuffer(0) },
willRespondWith: { status, body: badRequestResponse },
});
expect.assertions(3);
try {
await keyService.sendContent(mailboxId, content);
} catch (e) {
checkIfHttpError(e, status);
expect(e.response?.data).toStrictEqual(badRequestData);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment