-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from iway1/bugfix/void-inputs-and-auto-refetch
allows void / undefined inputs to send requests, no longer resends re…
- Loading branch information
Showing
5 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/trpc-panel/src/parse/input-mappers/__tests__/zod/void.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { defaultReferences } from "../../defaultReferences"; | ||
import { parseZodVoidDef } from "../../zod/parsers/parseZodVoidDef"; | ||
import { zodSelectorFunction } from "../../zod/selector"; | ||
import { LiteralNode } from "../../../parseNodeTypes"; | ||
import { z } from "zod"; | ||
|
||
describe("Parse ZodVoid", () => { | ||
it("should parse a void def as a literal node with undefined value", () => { | ||
const expected: LiteralNode = { | ||
type: "literal", | ||
path: [], | ||
value: undefined, | ||
}; | ||
const zodSchema = z.void(); | ||
const parsed = parseZodVoidDef(zodSchema._def, defaultReferences()); | ||
expect(parsed).toStrictEqual(expected); | ||
}); | ||
|
||
it("should be mapped correctly via the selector and parsed as a literal node", () => { | ||
const expected: LiteralNode = { | ||
type: "literal", | ||
path: [], | ||
value: undefined, | ||
}; | ||
const zodSchema = z.void(); | ||
const parsed = zodSelectorFunction(zodSchema._def, defaultReferences()); | ||
expect(parsed).toStrictEqual(expected); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
packages/trpc-panel/src/parse/input-mappers/zod/parsers/parseZodVoidDef.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { LiteralNode, ParseReferences } from "@src/parse/parseNodeTypes"; | ||
import { ZodVoidDef } from "zod"; | ||
|
||
export function parseZodVoidDef( | ||
_: ZodVoidDef, | ||
refs: ParseReferences | ||
): LiteralNode { | ||
return { | ||
type: "literal", | ||
value: undefined, | ||
path: refs.path, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters