Skip to content

Commit

Permalink
test: re-enable api type tests and fix type assertion (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Dec 21, 2022
1 parent 1d9102a commit 3d48658
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions test/fixture/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ interface TestResponse {
const $fetch = {} as $Fetch;

describe("API routes", () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const dynamicString = "";
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
const dynamicString: string = "";

it("generates types for middleware, unknown and manual typed routes", () => {
expectTypeOf($fetch("/")).toMatchTypeOf<Promise<unknown>>(); // middleware
Expand Down Expand Up @@ -68,22 +68,22 @@ describe("API routes", () => {
| { internalApiKey: "/api/typed/user/:userId" }
>
>();
// expectTypeOf(
// $fetch(`/api/typed/user/john/post/${dynamicString}`)
// ).toEqualTypeOf<
// Promise<
// | { internalApiKey: "/api/typed/user/john/post/coffee" }
// | { internalApiKey: "/api/typed/user/john/post/:postId" }
// >
// >();
// expectTypeOf(
// $fetch(`/api/typed/user/{someUserId}/post/${dynamicString}`)
// ).toEqualTypeOf<
// Promise<
// | { internalApiKey: "/api/typed/user/:userId/post/:postId" }
// | { internalApiKey: "/api/typed/user/:userId/post/firstPost" }
// >
// >();
expectTypeOf(
$fetch(`/api/typed/user/john/post/${dynamicString}`)
).toEqualTypeOf<
Promise<
| { internalApiKey: "/api/typed/user/john/post/coffee" }
| { internalApiKey: "/api/typed/user/john/post/:postId" }
>
>();
expectTypeOf(
$fetch(`/api/typed/user/{someUserId}/post/${dynamicString}`)
).toEqualTypeOf<
Promise<
| { internalApiKey: "/api/typed/user/:userId/post/:postId" }
| { internalApiKey: "/api/typed/user/:userId/post/firstPost" }
>
>();
expectTypeOf(
$fetch(`/api/typed/user/${dynamicString}/post/${dynamicString}`)
).toEqualTypeOf<
Expand Down

0 comments on commit 3d48658

Please sign in to comment.