Skip to content

Commit 8338336

Browse files
committed
TestValidator.httpError() to accept multile statuses.
1 parent 425c786 commit 8338336

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nestia/e2e",
3-
"version": "0.3.6",
3+
"version": "0.3.7",
44
"description": "E2E test utilify functions",
55
"main": "lib/index.js",
66
"scripts": {

packages/e2e/src/TestValidator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,16 @@ export namespace TestValidator {
103103

104104
export const httpError =
105105
(title: string) =>
106-
(status: number) =>
106+
(...statuses: number[]) =>
107107
<T>(task: () => T): T extends Promise<any> ? Promise<void> : void => {
108108
const message = (actual?: number) =>
109109
typeof actual === "number"
110-
? `Bug on ${title}: status code must be ${status}, but ${actual}.`
111-
: `Bug on ${title}: status code must be ${status}, but succeeded.`;
110+
? `Bug on ${title}: status code must be ${statuses.join(" or ")}, but ${actual}.`
111+
: `Bug on ${title}: status code must be ${statuses.join(" or ")}, but succeeded.`;
112112
const predicate = (exp: any): Error | null =>
113113
typeof exp === "object" &&
114114
exp.constructor.name === "HttpError" &&
115-
exp.status === status
115+
statuses.some(val => val === exp.status)
116116
? null
117117
: new Error(
118118
message(

0 commit comments

Comments
 (0)