/
opt
/
canhelp
/
node_modules
/
zod
/
src
/
v3
/
tests
/
/opt/canhelp/node_modules/zod/src/v3/tests
mkdir
upload
Name
Size
Mode
Actions
all-errors.test.ts
4753
0644
edit
dl
rm
anyunknown.test.ts
673
0644
edit
dl
rm
array.test.ts
1939
0644
edit
dl
rm
async-parsing.test.ts
12639
0644
edit
dl
rm
async-refinements.test.ts
1603
0644
edit
dl
rm
base.test.ts
782
0644
edit
dl
rm
bigint.test.ts
1977
0644
edit
dl
rm
branded.test.ts
1734
0644
edit
dl
rm
catch.test.ts
6550
0644
edit
dl
rm
coerce.test.ts
6650
0644
edit
dl
rm
complex.test.ts
1914
0644
edit
dl
rm
custom.test.ts
950
0644
edit
dl
rm
date.test.ts
983
0644
edit
dl
rm
deepmasking.test.ts
5215
0644
edit
dl
rm
default.test.ts
3527
0644
edit
dl
rm
description.test.ts
1323
0644
edit
dl
rm
discriminated-unions.test.ts
8537
0644
edit
dl
rm
enum.test.ts
2737
0644
edit
dl
rm
error.test.ts
16812
0644
edit
dl
rm
firstparty.test.ts
2391
0644
edit
dl
rm
firstpartyschematypes.test.ts
788
0644
edit
dl
rm
function.test.ts
6578
0644
edit
dl
rm
generics.test.ts
1523
0644
edit
dl
rm
instanceof.test.ts
1154
0644
edit
dl
rm
intersection.test.ts
3091
0644
edit
dl
rm
language-server.source.ts
1275
0644
edit
dl
rm
language-server.test.ts
8318
0644
edit
dl
rm
literal.test.ts
1063
0644
edit
dl
rm
map.test.ts
3545
0644
edit
dl
rm
masking.test.ts
85
0644
edit
dl
rm
mocker.test.ts
389
0644
edit
dl
rm
Mocker.ts
1341
0644
edit
dl
rm
nan.test.ts
587
0644
edit
dl
rm
nativeEnum.test.ts
2344
0644
edit
dl
rm
nullable.test.ts
1172
0644
edit
dl
rm
number.test.ts
6373
0644
edit
dl
rm
object-augmentation.test.ts
569
0644
edit
dl
rm
object-in-es5-env.test.ts
778
0644
edit
dl
rm
object.test.ts
11772
0644
edit
dl
rm
optional.test.ts
1222
0644
edit
dl
rm
parser.test.ts
1125
0644
edit
dl
rm
parseUtil.test.ts
869
0644
edit
dl
rm
partials.test.ts
6996
0644
edit
dl
rm
pickomit.test.ts
3622
0644
edit
dl
rm
pipeline.test.ts
823
0644
edit
dl
rm
preprocess.test.ts
4530
0644
edit
dl
rm
primitive.test.ts
12215
0644
edit
dl
rm
promise.test.ts
2490
0644
edit
dl
rm
readonly.test.ts
7339
0644
edit
dl
rm
record.test.ts
3735
0644
edit
dl
rm
recursive.test.ts
3946
0644
edit
dl
rm
refine.test.ts
8172
0644
edit
dl
rm
safeparse.test.ts
628
0644
edit
dl
rm
set.test.ts
4788
0644
edit
dl
rm
standard-schema.test.ts
2587
0644
edit
dl
rm
string.test.ts
65623
0644
edit
dl
rm
transformer.test.ts
5687
0644
edit
dl
rm
tuple.test.ts
2691
0644
edit
dl
rm
unions.test.ts
1540
0644
edit
dl
rm
validations.test.ts
3826
0644
edit
dl
rm
void.test.ts
349
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/zod/src/v3/tests/language-server.test.ts
(8318B)
import { test } from "vitest"; // import path from "path"; // import { Node, Project, SyntaxKind } from "ts-morph"; // import { filePath } from "./language-server.source"; // The following tool is helpful for understanding the TypeScript AST associated with these tests: // https://ts-ast-viewer.com/ (just copy the contents of language-server.source into the viewer) test("", () => {}); // describe("Executing Go To Definition (and therefore Find Usages and Rename Refactoring) using an IDE works on inferred object properties", () => { // // Compile file developmentEnvironment.source // const project = new Project({ // tsConfigFilePath: path.join(__dirname, "..", "..", "tsconfig.json"), // skipAddingFilesFromTsConfig: true, // }); // const sourceFile = project.addSourceFileAtPath(filePath); // test("works for object properties inferred from z.object()", () => { // // Find usage of Test.f1 property // const instanceVariable = // sourceFile.getVariableDeclarationOrThrow("instanceOfTest"); // const propertyBeingAssigned = getPropertyBeingAssigned( // instanceVariable, // "f1" // ); // // Find definition of Test.f1 property // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0]; // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind( // SyntaxKind.VariableDeclaration // ); // // Assert that find definition returned the Zod definition of Test // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()"); // expect(parentOfProperty?.getName()).toEqual("Test"); // }); // // test("works for first object properties inferred from z.object().merge()", () => { // // // Find usage of TestMerge.f1 property // // const instanceVariable = sourceFile.getVariableDeclarationOrThrow( // // "instanceOfTestMerge" // // ); // // const propertyBeingAssigned = getPropertyBeingAssigned( // // instanceVariable, // // "f1" // // ); // // // Find definition of TestMerge.f1 property // // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0]; // // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind( // // SyntaxKind.VariableDeclaration // // ); // // // Assert that find definition returned the Zod definition of Test // // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()"); // // expect(parentOfProperty?.getName()).toEqual("Test"); // // }); // // test("works for second object properties inferred from z.object().merge()", () => { // // // Find usage of TestMerge.f2 property // // const instanceVariable = sourceFile.getVariableDeclarationOrThrow( // // "instanceOfTestMerge" // // ); // // const propertyBeingAssigned = getPropertyBeingAssigned( // // instanceVariable, // // "f2" // // ); // // // Find definition of TestMerge.f2 property // // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0]; // // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind( // // SyntaxKind.VariableDeclaration // // ); // // // Assert that find definition returned the Zod definition of TestMerge // // expect(definitionOfProperty?.getText()).toEqual( // // "f2: z.string().optional()" // // ); // // expect(parentOfProperty?.getName()).toEqual("TestMerge"); // // }); // test("works for first object properties inferred from z.union()", () => { // // Find usage of TestUnion.f1 property // const instanceVariable = sourceFile.getVariableDeclarationOrThrow( // "instanceOfTestUnion" // ); // const propertyBeingAssigned = getPropertyBeingAssigned( // instanceVariable, // "f1" // ); // // Find definition of TestUnion.f1 property // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0]; // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind( // SyntaxKind.VariableDeclaration // ); // // Assert that find definition returned the Zod definition of Test // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()"); // expect(parentOfProperty?.getName()).toEqual("Test"); // }); // test("works for second object properties inferred from z.union()", () => { // // Find usage of TestUnion.f2 property // const instanceVariable = sourceFile.getVariableDeclarationOrThrow( // "instanceOfTestUnion" // ); // const propertyBeingAssigned = getPropertyBeingAssigned( // instanceVariable, // "f2" // ); // // Find definition of TestUnion.f2 property // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0]; // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind( // SyntaxKind.VariableDeclaration // ); // // Assert that find definition returned the Zod definition of TestUnion // expect(definitionOfProperty?.getText()).toEqual( // "f2: z.string().optional()" // ); // expect(parentOfProperty?.getName()).toEqual("TestUnion"); // }); // test("works for object properties inferred from z.object().partial()", () => { // // Find usage of TestPartial.f1 property // const instanceVariable = sourceFile.getVariableDeclarationOrThrow( // "instanceOfTestPartial" // ); // const propertyBeingAssigned = getPropertyBeingAssigned( // instanceVariable, // "f1" // ); // // Find definition of TestPartial.f1 property // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0]; // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind( // SyntaxKind.VariableDeclaration // ); // // Assert that find definition returned the Zod definition of Test // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()"); // expect(parentOfProperty?.getName()).toEqual("Test"); // }); // test("works for object properties inferred from z.object().pick()", () => { // // Find usage of TestPick.f1 property // const instanceVariable = // sourceFile.getVariableDeclarationOrThrow("instanceOfTestPick"); // const propertyBeingAssigned = getPropertyBeingAssigned( // instanceVariable, // "f1" // ); // // Find definition of TestPick.f1 property // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0]; // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind( // SyntaxKind.VariableDeclaration // ); // // Assert that find definition returned the Zod definition of Test // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()"); // expect(parentOfProperty?.getName()).toEqual("Test"); // }); // test("works for object properties inferred from z.object().omit()", () => { // // Find usage of TestOmit.f1 property // const instanceVariable = // sourceFile.getVariableDeclarationOrThrow("instanceOfTestOmit"); // const propertyBeingAssigned = getPropertyBeingAssigned( // instanceVariable, // "f1" // ); // // Find definition of TestOmit.f1 property // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0]; // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind( // SyntaxKind.VariableDeclaration // ); // // Assert that find definition returned the Zod definition of Test // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()"); // expect(parentOfProperty?.getName()).toEqual("Test"); // }); // }); // const getPropertyBeingAssigned = (node: Node, name: string) => { // const propertyAssignment = node.forEachDescendant((descendent) => // Node.isPropertyAssignment(descendent) && descendent.getName() == name // ? descendent // : undefined // ); // if (propertyAssignment == null) // fail(`Could not find property assignment with name ${name}`); // const propertyLiteral = propertyAssignment.getFirstDescendantByKind( // SyntaxKind.Identifier // ); // if (propertyLiteral == null) // fail(`Could not find property literal with name ${name}`); // return propertyLiteral; // };
Save
cmd:
run