@@ -2,11 +2,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
22import { makeClientWithInferredTypes } from "./api-client" ;
33import { Client } from "./api-client-types" ;
44import * as MockAPI from "../test-util/api-server" ;
5- import { complicatedBasePath } from "../test-util/long-base-path-api" ;
65
76describe ( "API Client" , ( ) => {
87 describe ( "configuration options" , ( ) => {
9- let client : Client < MockAPI . API , MockAPI . Config > ;
8+ let client : Client < MockAPI . API , MockAPI . ClientConfig > ;
109 let mockFetch : typeof fetch ;
1110
1211 beforeEach ( ( ) => {
@@ -16,7 +15,9 @@ describe("API Client", () => {
1615 basePath : "/api" as const ,
1716 urlCase : "camel" ,
1817 } ;
19- client = makeClientWithInferredTypes < MockAPI . API , MockAPI . Config > ( config ) ;
18+ client = makeClientWithInferredTypes < MockAPI . API , MockAPI . ClientConfig > (
19+ config
20+ ) ;
2021 } ) ;
2122
2223 afterEach ( ( ) => {
@@ -33,22 +34,24 @@ describe("API Client", () => {
3334 } ) ;
3435
3536 describe ( "long base paths" , ( ) => {
36- let client : Client <
37- MockAPI . APIWithCustomBasePathAPI ,
38- MockAPI . APIWithCustomBasePathConfig
39- > ;
37+ const longBasePath = "/api/camelCase/kebab-case/v2" as const ;
38+ type LongBasePath = typeof longBasePath ;
39+ type ClientConfigWithLongBasePath = {
40+ basePath : LongBasePath ;
41+ } ;
42+ let client : Client < MockAPI . API , ClientConfigWithLongBasePath > ;
4043 let mockFetch : typeof fetch ;
4144
4245 beforeEach ( ( ) => {
4346 mockFetch = vi . fn ( MockAPI . mockFetchImplementation ) ;
4447 const config = {
4548 fetch : mockFetch ,
46- basePath : complicatedBasePath ,
49+ basePath : longBasePath ,
4750 urlCase : "camel" ,
4851 } ;
4952 client = makeClientWithInferredTypes <
50- MockAPI . APIWithCustomBasePathAPI ,
51- MockAPI . APIWithCustomBasePathConfig
53+ MockAPI . API ,
54+ ClientConfigWithLongBasePath
5255 > ( config ) ;
5356 } ) ;
5457
@@ -69,13 +72,15 @@ describe("API Client", () => {
6972 } ) ;
7073
7174 describe ( "fetch calls" , ( ) => {
72- let client : Client < MockAPI . API , MockAPI . Config > ;
75+ let client : Client < MockAPI . API , MockAPI . ClientConfig > ;
7376 let mockFetch : typeof fetch ;
7477
7578 beforeEach ( ( ) => {
7679 mockFetch = vi . fn ( MockAPI . mockFetchImplementation ) ;
7780 const config = { fetch : mockFetch , basePath : "/api" as const } ;
78- client = makeClientWithInferredTypes < MockAPI . API , MockAPI . Config > ( config ) ;
81+ client = makeClientWithInferredTypes < MockAPI . API , MockAPI . ClientConfig > (
82+ config
83+ ) ;
7984 } ) ;
8085
8186 afterEach ( ( ) => {
@@ -138,15 +143,17 @@ describe("API Client", () => {
138143 } ) ;
139144
140145 describe ( "`useMethod` style call" , ( ) => {
141- let client : Client < MockAPI . API , MockAPI . Config > ;
146+ let client : Client < MockAPI . API , MockAPI . ClientConfig > ;
142147 let mockFetch : typeof fetch ;
143148
144149 beforeEach ( ( ) => {
145150 mockFetch = vi
146151 . fn ( fetch )
147152 . mockImplementation ( MockAPI . mockFetchImplementation ) ;
148153 const config = { fetch : mockFetch , basePath : "/api" as const } ;
149- client = makeClientWithInferredTypes < MockAPI . API , MockAPI . Config > ( config ) ;
154+ client = makeClientWithInferredTypes < MockAPI . API , MockAPI . ClientConfig > (
155+ config
156+ ) ;
150157 } ) ;
151158
152159 afterEach ( ( ) => {
0 commit comments