Skip to content

Commit

Permalink
test: add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMendes98 committed Sep 18, 2024
1 parent 3032e24 commit 0c46ca0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/__tests__/error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,16 @@ test("formatting", () => {
if (!result2.success) {
type FormattedError = z.inferFormattedError<typeof schema, number>;
const error: FormattedError = result2.error.format(() => 5);
expect(error._errors).toEqual([]);
expect(error.inner?._errors).toEqual([]);
expect(error.inner?.name?._errors).toEqual([5]);

type FormattedErrors = number[] | undefined;
const schemaErrors: FormattedErrors = error._errors;
const innerErrors: FormattedErrors = error.inner?._errors;
// @ts-expect-error it should not be the default formatted type
const nameErrors: string[] | undefined = error.inner?.name?._errors;

expect(schemaErrors).toEqual([]);
expect(innerErrors).toEqual([]);
expect(nameErrors).toEqual([5]);
}
});

Expand Down

0 comments on commit 0c46ca0

Please sign in to comment.