Skip to content

Commit 74afc7c

Browse files
committed
test for working with validators
1 parent 60006f5 commit 74afc7c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/convex-helpers/index.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { v } from "convex/values";
12
import { withoutSystemFields } from "./index.js";
23
import { test, expect, expectTypeOf } from "vitest";
34

@@ -27,3 +28,14 @@ test("withoutSystemFields type when it's a union", () => {
2728
expect(without2).toEqual({ a: "a" });
2829
expectTypeOf(without2).toEqualTypeOf<{ a: string } | { b: string }>();
2930
});
31+
32+
test("withoutSystemFields works on validators too", () => {
33+
const validator = v.object({
34+
_id: v.string(),
35+
_creationTime: v.number(),
36+
a: v.string(),
37+
});
38+
const { _id, _creationTime, ...rest } = validator.fields;
39+
const without = withoutSystemFields(validator.fields);
40+
expectTypeOf(without).toEqualTypeOf<typeof rest>();
41+
});

0 commit comments

Comments
 (0)