server/api/api/v1/accounts/id/index.test.ts
Jesse Wierzbinski e3e285571e
Some checks failed
Mirror to Codeberg / Mirror (push) Failing after 0s
refactor(api): 🏷️ Port all /api/v1/accounts to use new schemas
2025-02-13 01:31:15 +01:00

33 lines
941 B
TypeScript

import { afterAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
const { users, deleteUsers } = await getTestUsers(5);
afterAll(async () => {
await deleteUsers();
});
// /api/v1/accounts/id
describe("/api/v1/accounts/id", () => {
test("should correctly get user from username", async () => {
const response = await fakeRequest(
`/api/v1/accounts/id?username=${users[0].data.username}`,
);
expect(response.status).toBe(200);
const data = (await response.json()) as ApiAccount;
expect(data.id).toBe(users[0].id);
});
test("should return 404 for non-existent user", async () => {
const response = await fakeRequest(
"/api/v1/accounts/id?username=nonexistent",
);
expect(response.status).toBe(404);
});
});