Skip to content

Commit cfdff24

Browse files
committed
✨ feat(sub-calendars): fix test
1 parent 028e157 commit cfdff24

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

packages/core/src/types/type.utils.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
import { ZodError as ZodErrorV3 } from "zod";
12
import { ZodError, z } from "zod/v4";
23
import { faker } from "@faker-js/faker";
3-
import { IDSchema, RGBHexSchema, TimezoneSchema } from "@core/types/type.utils";
4+
import {
5+
IDSchema,
6+
IDSchemaV4,
7+
RGBHexSchema,
8+
TimezoneSchema,
9+
} from "@core/types/type.utils";
410

511
describe("IDSchema", () => {
612
it("validates a correct ObjectId string", () => {
@@ -13,6 +19,27 @@ describe("IDSchema", () => {
1319
const invalidId = faker.string.ulid();
1420
const result = IDSchema.safeParse(invalidId);
1521

22+
expect(result.success).toBe(false);
23+
expect(result.error).toBeInstanceOf(ZodErrorV3);
24+
expect(result.error?.errors).toEqual(
25+
expect.arrayContaining([
26+
expect.objectContaining({ message: "Invalid id" }),
27+
]),
28+
);
29+
});
30+
});
31+
32+
describe("IDSchemaV4", () => {
33+
it("validates a correct ObjectId string", () => {
34+
const validId = faker.database.mongodbObjectId();
35+
36+
expect(IDSchemaV4.safeParse(validId).success).toBe(true);
37+
});
38+
39+
it("rejects an invalid ObjectId string", () => {
40+
const invalidId = faker.string.ulid();
41+
const result = IDSchemaV4.safeParse(invalidId);
42+
1643
expect(result.success).toBe(false);
1744
expect(result.error).toBeInstanceOf(ZodError);
1845
expect(z.treeifyError(result.error!).errors).toEqual(["Invalid id"]);

0 commit comments

Comments
 (0)