First Commit. Duplicate bunext-sqlite preset

This commit is contained in:
2026-10-18 16:47:11 +01:00
commit 81e4a8aecc
718 changed files with 41695 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import { describe, expect, test } from "bun:test";
import { z } from "zod";
import AppError from "./app-error";
import parseWithSchema from "./parse-with-schema";
const Schema = z.object({
email: z.email("Please enter a valid email address"),
age: z.number().min(18, "You must be at least 18"),
});
describe("parseWithSchema", () => {
test("returns the parsed data for valid input", () => {
expect(
parseWithSchema({
schema: Schema,
data: { email: "[email protected]", age: 30 },
}),
).toEqual({ email: "[email protected]", age: 30 });
});
test("throws an AppError with the first issue message", () => {
expect(() =>
parseWithSchema({
schema: Schema,
data: { email: "not-an-email", age: 30 },
}),
).toThrow(AppError);
});
test("throws for non-object input", () => {
expect(() =>
parseWithSchema({ schema: Schema, data: null }),
).toThrow(AppError);
});
});