Skip to content

Commit

Permalink
test(middleware): remove args from next function
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEdoRan committed Aug 11, 2024
1 parent 97587ae commit e70a74b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions packages/next-safe-action/src/__tests__/middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test("instance context value is correctly overridden in subsequent middleware",
if (ctx.foo !== "baz") {
throw new Error("Expected ctx.foo to be 'baz'");
}
return next({ ctx });
return next();
})
.action(async ({ ctx }) => {
return {
Expand Down Expand Up @@ -130,9 +130,9 @@ test("happy path execution result from middleware is correct", async () => {
})
)
.bindArgsSchemas([z.object({ age: z.number().positive() })])
.use(async ({ next, ctx }) => {
.use(async ({ next }) => {
// Await action execution.
const res = await next({ ctx });
const res = await next();
middlewareResult = res;
return res;
})
Expand Down Expand Up @@ -176,9 +176,9 @@ test("server error execution result from middleware is correct", async () => {
})
)
.bindArgsSchemas([z.object({ age: z.number().positive() })])
.use(async ({ next, ctx }) => {
.use(async ({ next }) => {
// Await action execution.
const res = await next({ ctx });
const res = await next();
middlewareResult = res;
return res;
})
Expand Down Expand Up @@ -212,9 +212,9 @@ test("validation errors in execution result from middleware are correct", async
})
)
.bindArgsSchemas([z.object({ age: z.number().positive() })])
.use(async ({ next, ctx }) => {
.use(async ({ next }) => {
// Await action execution.
const res = await next({ ctx });
const res = await next();
middlewareResult = res;
return res;
})
Expand Down Expand Up @@ -259,9 +259,9 @@ test("server validation errors in execution result from middleware are correct",
const action = ac
.schema(schema)
.bindArgsSchemas([z.object({ age: z.number().positive() })])
.use(async ({ next, ctx }) => {
.use(async ({ next }) => {
// Await action execution.
const res = await next({ ctx });
const res = await next();
middlewareResult = res;
return res;
})
Expand Down Expand Up @@ -309,9 +309,9 @@ test("flattened validation errors in execution result from middleware are correc
})
)
.bindArgsSchemas([z.object({ age: z.number().positive() })])
.use(async ({ next, ctx }) => {
.use(async ({ next }) => {
// Await action execution.
const res = await next({ ctx });
const res = await next();
middlewareResult = res;
return res;
})
Expand Down Expand Up @@ -360,9 +360,9 @@ test("overridden formatted validation errors in execution result from middleware
.bindArgsSchemas([z.object({ age: z.number().positive() })], {
handleBindArgsValidationErrorsShape: formatBindArgsValidationErrors,
})
.use(async ({ next, ctx }) => {
.use(async ({ next }) => {
// Await action execution.
const res = await next({ ctx });
const res = await next();
middlewareResult = res;
return res;
})
Expand Down
8 changes: 4 additions & 4 deletions packages/next-safe-action/src/__tests__/server-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test("unknown error occurred in server code function is masked by default", asyn

test("unknown error occurred in middleware function is masked by default", async () => {
const action = ac1
.use(async ({ next, ctx }) => next({ ctx }))
.use(async ({ next }) => next())
.use(async () => {
throw new Error("Something bad happened");
})
Expand Down Expand Up @@ -74,7 +74,7 @@ test("known error occurred in server code function is unmasked", async () => {

test("known error occurred in middleware function is unmasked", async () => {
const action = ac1
.use(async ({ next, ctx }) => next({ ctx }))
.use(async ({ next }) => next())
.use(async () => {
throw new ActionError("Something bad happened");
})
Expand Down Expand Up @@ -131,7 +131,7 @@ test("error occurred in server code function has the correct shape defined by `h

test("error occurred in middleware function has the correct shape defined by `handleReturnedServerError`", async () => {
const action = ac2
.use(async ({ next, ctx }) => next({ ctx }))
.use(async ({ next }) => next())
.use(async () => {
throw new Error("Something bad happened");
})
Expand Down Expand Up @@ -169,7 +169,7 @@ test("action throws if an error occurred in server code function and `handleRetu

test("action throws if an error occurred in middleware function and `handleReturnedServerError` rethrows it", async () => {
const action = ac3
.use(async ({ next, ctx }) => next({ ctx }))
.use(async ({ next }) => next())
.use(async () => {
throw new Error("Something bad happened");
})
Expand Down

0 comments on commit e70a74b

Please sign in to comment.