61 lines
1.7 KiB
TypeScript
61 lines
1.7 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("User 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 return user profile", async () => {
|
|
const token = "this-is-a-very-clean-token";
|
|
const res = await client["v1"].me.$get(
|
|
{},
|
|
{
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
}
|
|
);
|
|
|
|
// Auth middleware is initialized but the test Supabase client returns an error
|
|
assert.ok(res.status >= 400);
|
|
});
|
|
|
|
it("should sign up user to stream", async () => {
|
|
const token = "this-is-a-very-clean-token";
|
|
const res = await client["sign-up-to-stream"].$post(
|
|
{},
|
|
{
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
}
|
|
);
|
|
|
|
assert.ok(res.status >= 400);
|
|
});
|
|
|
|
it("should mark user as temporary", async () => {
|
|
const token = "this-is-a-very-clean-token";
|
|
const res = await client["mark-temporary"].$post(
|
|
{},
|
|
{
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
}
|
|
);
|
|
|
|
assert.ok(res.status >= 400);
|
|
});
|
|
});
|