xtablo-source/apps/api/src/__tests__/tablo/tablo.test.ts
2025-11-10 08:52:47 +01:00

91 lines
2.3 KiB
TypeScript

import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { testClient } from "hono/testing";
import { createConfig } from "../../config.js";
import { MiddlewareManager } from "../../middlewares/middleware.js";
import { getMainRouter } from "../../routers/index.js";
describe("Tablo Endpoint", () => {
// In test mode, createConfig() reads from .env.test
const config = createConfig();
MiddlewareManager.initialize(config);
const app = getMainRouter(config);
// biome-ignore lint/suspicious/noExplicitAny: testClient requires any for dynamic route access
const client = testClient(app) as any;
it("should create tablo", async () => {
const token = "this-is-a-very-clean-token";
const res = await client["v1"].tablos.create.$post(
{
json: {
name: "Test Tablo",
status: "todo",
},
},
{
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
}
);
assert.ok(res.status >= 400);
});
it("should update tablo", async () => {
const token = "this-is-a-very-clean-token";
const res = await client["v1"].tablos.update.$patch(
{
json: {
id: "123",
name: "Updated Tablo",
},
},
{
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
}
);
assert.ok(res.status >= 400);
});
it("should delete tablo", async () => {
const token = "this-is-a-very-clean-token";
const res = await client["v1"].tablos.delete.$delete(
{
json: {
id: "123",
},
},
{
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
}
);
assert.ok(res.status >= 400);
});
it("should get tablo members", async () => {
const token = "this-is-a-very-clean-token";
const res = await client["v1"].tablos.members[":tablo_id"].$get(
{
param: { tablo_id: "123" },
},
{
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
}
);
assert.ok(res.status >= 400);
});
});