2022-09-15 01:58:08 +02:00
|
|
|
import { Response } from "node-fetch"
|
|
|
|
|
2022-09-05 19:28:53 +02:00
|
|
|
// boilerplate to allow TS updates to the global scope
|
2022-09-15 01:58:08 +02:00
|
|
|
export {}
|
2022-09-05 19:28:53 +02:00
|
|
|
|
|
|
|
declare global {
|
|
|
|
namespace jest {
|
|
|
|
interface Matchers<R> {
|
2022-09-15 01:58:08 +02:00
|
|
|
toHaveStatusCode(code: number): R
|
2022-09-05 19:28:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Expect extensions
|
|
|
|
expect.extend({
|
2022-09-15 01:58:08 +02:00
|
|
|
toHaveStatusCode(received: Response, code: number) {
|
2022-09-05 19:28:53 +02:00
|
|
|
const pass = received.status === code
|
|
|
|
return {
|
2022-09-15 01:58:08 +02:00
|
|
|
message: () => `expected ${received.status} to match status code ${code}`,
|
2022-09-05 19:28:53 +02:00
|
|
|
pass,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|