-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commons): Add expectStatus jest testing helper
- Loading branch information
Lukas Fritze
committed
Mar 8, 2024
1 parent
48692f2
commit f6a3e63
Showing
5 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect } from "@jest/globals"; | ||
import assertStatus from "../types/assertStatus.js"; | ||
import { Response } from "../types/Response.js"; | ||
|
||
export function expectStatus<T extends Response, S extends T["status"]>( | ||
response: T, | ||
status: S, | ||
): asserts response is T & { status: S } { | ||
expect(response.status).toBe(status); | ||
assertStatus(response, status); | ||
} | ||
|
||
export default expectStatus; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./expectStatus.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