1
1
import { test , type TestContext } from "node:test" ;
2
2
import { 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" ;
4
4
import type { Routes } from "./generated.ts" ;
5
5
6
6
await test ( "fetch()" , async ( t ) => {
@@ -44,7 +44,7 @@ await test("fetch()", async (t) => {
44
44
const res = await client . get ( "/simple" ) ;
45
45
t . assert . equal ( res . status , 200 ) ;
46
46
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 } ) ;
48
48
} ) ;
49
49
50
50
await t . test ( "/query" , async ( t : TestContext ) => {
@@ -53,13 +53,13 @@ await test("fetch()", async (t) => {
53
53
const withoutQueryRes = await client . get ( "/query" ) ;
54
54
t . assert . equal ( withoutQueryRes . status , 200 ) ;
55
55
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 } ) ;
57
57
58
58
const query : QueryType < routeType > = { flag : true } ;
59
59
const withQueryRes = await client . get ( "/query" , { query } ) ;
60
60
t . assert . equal ( withQueryRes . status , 200 ) ;
61
61
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 } ) ;
63
63
} ) ;
64
64
65
65
await t . test ( "/param/{param}" , async ( t : TestContext ) => {
@@ -68,11 +68,11 @@ await test("fetch()", async (t) => {
68
68
const passingRes = await client . get ( "/param/{param}" , { params : { param : "pass" } } ) ;
69
69
t . assert . equal ( passingRes . status , 200 ) ;
70
70
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 } ) ;
72
72
73
73
const failingRes = await client . get ( "/param/{param}" , { params : { param : "fail" } } ) ;
74
74
t . assert . equal ( failingRes . status , 400 ) ;
75
75
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" } ) ;
77
77
} ) ;
78
78
} ) ;
0 commit comments