mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-25 00:22:43 -05:00
add tests
This commit is contained in:
32
packages/better-auth/src/db/to-zod.test.ts
Normal file
32
packages/better-auth/src/db/to-zod.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { toZodSchema } from "./to-zod";
|
||||
|
||||
describe("toZodSchema", () => {
|
||||
describe("returned: false field handling (issue #7489)", () => {
|
||||
it("should include fields with returned: false in input schema (isClientSide: true)", () => {
|
||||
const schema = toZodSchema({
|
||||
fields: {
|
||||
name: { type: "string", required: true },
|
||||
secretField: { type: "string", required: true, returned: false },
|
||||
},
|
||||
isClientSide: true,
|
||||
});
|
||||
|
||||
expect(schema.shape).toHaveProperty("name");
|
||||
expect(schema.shape).toHaveProperty("secretField");
|
||||
});
|
||||
|
||||
it("should exclude fields with returned: false from output schema (isClientSide: false)", () => {
|
||||
const schema = toZodSchema({
|
||||
fields: {
|
||||
name: { type: "string", required: true },
|
||||
secretField: { type: "string", required: true, returned: false },
|
||||
},
|
||||
isClientSide: false,
|
||||
});
|
||||
|
||||
expect(schema.shape).toHaveProperty("name");
|
||||
expect(schema.shape).not.toHaveProperty("secretField");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user