11import { test , type TestContext } from "node:test" ;
22import { server , Client } from "./fixture.ts" ;
3- import type { MatchingRoute , QueryType , SpecificResultType } from "@code4rena/typed-client" ;
3+ import type { MatchingRoute , QueryType , SpecificBodyType } from "@code4rena/typed-client" ;
44import type { Routes } from "./generated.ts" ;
55
66await test ( "fetch()" , async ( t ) => {
@@ -44,7 +44,7 @@ await test("fetch()", async (t) => {
4444 const res = await client . get ( "/simple" ) ;
4545 t . assert . equal ( res . status , 200 ) ;
4646 t . assert . equal ( res . url , `${ server . info . uri } /simple` ) ;
47- t . assert . deepStrictEqual < SpecificResultType < routeType , 200 > > ( res . data , { success : true } ) ;
47+ t . assert . deepStrictEqual < SpecificBodyType < routeType , 200 > > ( res . body , { success : true } ) ;
4848 } ) ;
4949
5050 await t . test ( "/query" , async ( t : TestContext ) => {
@@ -53,13 +53,13 @@ await test("fetch()", async (t) => {
5353 const withoutQueryRes = await client . get ( "/query" ) ;
5454 t . assert . equal ( withoutQueryRes . status , 200 ) ;
5555 t . assert . equal ( withoutQueryRes . url , `${ server . info . uri } /query` ) ;
56- t . assert . deepStrictEqual < SpecificResultType < routeType , 200 > > ( withoutQueryRes . data , { flag : false } ) ;
56+ t . assert . deepStrictEqual < SpecificBodyType < routeType , 200 > > ( withoutQueryRes . body , { flag : false } ) ;
5757
5858 const query : QueryType < routeType > = { flag : true } ;
5959 const withQueryRes = await client . get ( "/query" , { query } ) ;
6060 t . assert . equal ( withQueryRes . status , 200 ) ;
6161 t . assert . equal ( withQueryRes . url , `${ server . info . uri } /query?flag=true` ) ;
62- t . assert . deepStrictEqual < SpecificResultType < routeType , 200 > > ( withQueryRes . data , { flag : true } ) ;
62+ t . assert . deepStrictEqual < SpecificBodyType < routeType , 200 > > ( withQueryRes . body , { flag : true } ) ;
6363 } ) ;
6464
6565 await t . test ( "/param/{param}" , async ( t : TestContext ) => {
@@ -68,11 +68,11 @@ await test("fetch()", async (t) => {
6868 const passingRes = await client . get ( "/param/{param}" , { params : { param : "pass" } } ) ;
6969 t . assert . equal ( passingRes . status , 200 ) ;
7070 t . assert . equal ( passingRes . url , `${ server . info . uri } /param/pass` ) ;
71- t . assert . deepStrictEqual < SpecificResultType < routeType , 200 > > ( passingRes . data , { success : true } ) ;
71+ t . assert . deepStrictEqual < SpecificBodyType < routeType , 200 > > ( passingRes . body , { success : true } ) ;
7272
7373 const failingRes = await client . get ( "/param/{param}" , { params : { param : "fail" } } ) ;
7474 t . assert . equal ( failingRes . status , 400 ) ;
7575 t . assert . equal ( failingRes . url , `${ server . info . uri } /param/fail` ) ;
76- t . assert . deepStrictEqual < SpecificResultType < routeType , 400 > > ( failingRes . data , { success : false , message : "failed" } ) ;
76+ t . assert . deepStrictEqual < SpecificBodyType < routeType , 400 > > ( failingRes . body , { success : false , message : "failed" } ) ;
7777 } ) ;
7878} ) ;
0 commit comments