Created
October 27, 2022 18:21
-
-
Save liannoi/1f778f255252101e5c278abc9bb80bba to your computer and use it in GitHub Desktop.
Feature Request for Pact Foundation (pact-js)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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