Route and MCP test files were calling createTestDb() without await, causing db to be a Promise object instead of a Drizzle instance. Also rewrote auth route tests for OIDC-based auth (merge picked old version). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { beforeEach, describe, expect, test } from "bun:test";
|
|
import { Hono } from "hono";
|
|
import { imageRoutes } from "../../src/server/routes/images";
|
|
import { createTestDb } from "../helpers/db.ts";
|
|
|
|
let app: Hono;
|
|
|
|
beforeEach(async () => {
|
|
const { db, userId } = await createTestDb();
|
|
app = new Hono();
|
|
app.use("*", async (c, next) => {
|
|
c.set("db", db);
|
|
c.set("userId", userId);
|
|
await next();
|
|
});
|
|
app.route("/api/images", imageRoutes);
|
|
});
|
|
|
|
describe("POST /api/images/from-url", () => {
|
|
test("returns 400 for missing URL", async () => {
|
|
const res = await app.request("/api/images/from-url", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({}),
|
|
});
|
|
expect(res.status).toBe(400);
|
|
});
|
|
|
|
test("returns 400 for invalid URL", async () => {
|
|
const res = await app.request("/api/images/from-url", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ url: "not-a-url" }),
|
|
});
|
|
expect(res.status).toBe(400);
|
|
});
|
|
});
|