forked from colinhacks/zod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseUtil.test.ts
More file actions
28 lines (23 loc) · 877 Bytes
/
parseUtil.test.ts
File metadata and controls
28 lines (23 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// @ts-ignore TS6133
import { expect, test } from "@jest/globals";
import {
isAborted,
isDirty,
isValid,
SyncParseReturnType,
} from "../helpers/parseUtil";
test("parseUtil isInvalid should use structural typing", () => {
// Test for issue #556: https://github.com/colinhacks/zod/issues/556
const aborted: SyncParseReturnType = { status: "aborted" };
const dirty: SyncParseReturnType = { status: "dirty", value: "whatever" };
const valid: SyncParseReturnType = { status: "valid", value: "whatever" };
expect(isAborted(aborted)).toBe(true);
expect(isAborted(dirty)).toBe(false);
expect(isAborted(valid)).toBe(false);
expect(isDirty(aborted)).toBe(false);
expect(isDirty(dirty)).toBe(true);
expect(isDirty(valid)).toBe(false);
expect(isValid(aborted)).toBe(false);
expect(isValid(dirty)).toBe(false);
expect(isValid(valid)).toBe(true);
});