@@ -2,11 +2,11 @@ import { describe, expect, it, jest } from 'bun:test';
22import { NextAction } from '../src/next/action.js' ;
33import { z } from 'zod' ;
44
5+ const nextAction = new NextAction ( { } ) ;
6+
57describe ( 'Next.js Action' , ( ) => {
68 it ( 'create nextjs server action' , async ( ) => {
7- const aa = new NextAction ( { } ) ;
8-
9- const action = aa
9+ const action = nextAction
1010 . post ( '/say' , { actionName : 'sayHello' } )
1111 . validator (
1212 z . object ( {
@@ -36,9 +36,7 @@ describe('Next.js Action', () => {
3636 } ) ;
3737
3838 it ( 'create nextjs server action with bindArgs' , async ( ) => {
39- const aa = new NextAction ( { } ) ;
40-
41- const action = aa
39+ const action = nextAction
4240 . post ( )
4341 . validator (
4442 z . object ( {
@@ -58,21 +56,23 @@ describe('Next.js Action', () => {
5856 expect ( action . bind ( null , 'Hi' ) ( formData ) ) . resolves . toEqual ( {
5957 message : 'Hi, tom' ,
6058 } ) ;
59+ expect ( action . bind ( null , 'Hi' ) ( { name : 'tom' } ) ) . resolves . toEqual ( {
60+ message : 'Hi, tom' ,
61+ } ) ;
6162 } ) ;
6263
6364 it ( 'create nextjs server action with middleware' , async ( ) => {
64- const aa = new NextAction ( { } ) ;
6565 const middleware = jest . fn ( async ( opts ) => {
6666 await opts . next ( ) ;
6767 } ) ;
6868
69- const aa2 = aa . use ( middleware ) ;
69+ const withMiddleware = nextAction . use ( middleware ) ;
7070
71- const action = aa . post ( ) . action ( async ( ) => {
71+ const action = nextAction . post ( ) . action ( async ( ) => {
7272 return { message : 'without middleware' } ;
7373 } ) ;
7474
75- const action2 = aa2 . post ( ) . action ( async ( ) => {
75+ const action2 = withMiddleware . post ( ) . action ( async ( ) => {
7676 return { message : 'with middleware' } ;
7777 } ) ;
7878
@@ -82,9 +82,7 @@ describe('Next.js Action', () => {
8282 } ) ;
8383
8484 it ( 'create nextjs server action with selector' , async ( ) => {
85- const aa = new NextAction ( { } ) ;
86-
87- const action = aa
85+ const action = nextAction
8886 . post ( )
8987 . validator (
9088 z . object ( {
0 commit comments