@@ -1232,25 +1232,68 @@ describe('standalone adapter', () => {
12321232
12331233 test ( 'with coerce' , async ( ) => {
12341234 const appRouter = t . router ( {
1235- plusOne : t . procedure
1235+ getPlusOne : t . procedure
12361236 . meta ( { openapi : { method : 'GET' , path : '/plus-one' } } )
12371237 . input ( z . object ( { number : z . number ( ) } ) )
12381238 . output ( z . object ( { result : z . number ( ) } ) )
12391239 . query ( ( { input } ) => ( { result : input . number + 1 } ) ) ,
1240+ postPlusOne : t . procedure
1241+ . meta ( { openapi : { method : 'POST' , path : '/plus-one' } } )
1242+ . input ( z . object ( { date : z . date ( ) } ) )
1243+ . output ( z . object ( { result : z . number ( ) } ) )
1244+ . mutation ( ( { input } ) => ( { result : input . date . getTime ( ) + 1 } ) ) ,
1245+ pathPlusOne : t . procedure
1246+ . meta ( { openapi : { method : 'GET' , path : '/plus-one/{number}' } } )
1247+ . input ( z . object ( { number : z . number ( ) } ) )
1248+ . output ( z . object ( { result : z . number ( ) } ) )
1249+ . query ( ( { input } ) => ( { result : input . number + 1 } ) ) ,
12401250 } ) ;
12411251
12421252 const { url, close } = createHttpServerWithRouter ( {
12431253 router : appRouter ,
12441254 } ) ;
12451255
1246- const res = await fetch ( `${ url } /plus-one?number=9` , { method : 'GET' } ) ;
1247- const body = await res . json ( ) ;
1256+ {
1257+ const res = await fetch ( `${ url } /plus-one?number=9` , { method : 'GET' } ) ;
1258+ const body = await res . json ( ) ;
12481259
1249- expect ( res . status ) . toBe ( 200 ) ;
1250- expect ( body ) . toEqual ( { result : 10 } ) ;
1251- expect ( createContextMock ) . toHaveBeenCalledTimes ( 1 ) ;
1252- expect ( responseMetaMock ) . toHaveBeenCalledTimes ( 1 ) ;
1253- expect ( onErrorMock ) . toHaveBeenCalledTimes ( 0 ) ;
1260+ expect ( res . status ) . toBe ( 200 ) ;
1261+ expect ( body ) . toEqual ( { result : 10 } ) ;
1262+ expect ( createContextMock ) . toHaveBeenCalledTimes ( 1 ) ;
1263+ expect ( responseMetaMock ) . toHaveBeenCalledTimes ( 1 ) ;
1264+ expect ( onErrorMock ) . toHaveBeenCalledTimes ( 0 ) ;
1265+
1266+ clearMocks ( ) ;
1267+ }
1268+ {
1269+ const date = new Date ( ) ;
1270+
1271+ const res = await fetch ( `${ url } /plus-one` , {
1272+ method : 'POST' ,
1273+ headers : { 'Content-Type' : 'application/json' } ,
1274+ body : JSON . stringify ( { date } ) ,
1275+ } ) ;
1276+ const body = await res . json ( ) ;
1277+
1278+ expect ( res . status ) . toBe ( 200 ) ;
1279+ expect ( body ) . toEqual ( { result : date . getTime ( ) + 1 } ) ;
1280+ expect ( createContextMock ) . toHaveBeenCalledTimes ( 1 ) ;
1281+ expect ( responseMetaMock ) . toHaveBeenCalledTimes ( 1 ) ;
1282+ expect ( onErrorMock ) . toHaveBeenCalledTimes ( 0 ) ;
1283+
1284+ clearMocks ( ) ;
1285+ }
1286+
1287+ {
1288+ const res = await fetch ( `${ url } /plus-one/9` , { method : 'GET' } ) ;
1289+ const body = await res . json ( ) ;
1290+
1291+ expect ( res . status ) . toBe ( 200 ) ;
1292+ expect ( body ) . toEqual ( { result : 10 } ) ;
1293+ expect ( createContextMock ) . toHaveBeenCalledTimes ( 1 ) ;
1294+ expect ( responseMetaMock ) . toHaveBeenCalledTimes ( 1 ) ;
1295+ expect ( onErrorMock ) . toHaveBeenCalledTimes ( 0 ) ;
1296+ }
12541297
12551298 close ( ) ;
12561299 } ) ;
0 commit comments