mirror of
https://github.com/versia-pub/server.git
synced 2025-12-10 10:18:20 +01:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { afterAll, describe, expect, test } from "bun:test";
|
|
import type { Account as ApiAccount } from "@versia/client/types";
|
|
import { fakeRequest, getTestUsers } from "~/tests/utils";
|
|
import { meta } from "./index.ts";
|
|
|
|
const { users, tokens, deleteUsers } = await getTestUsers(5);
|
|
|
|
afterAll(async () => {
|
|
await deleteUsers();
|
|
});
|
|
|
|
// /api/v1/accounts/search
|
|
describe(meta.route, () => {
|
|
test("should return 200 with users", async () => {
|
|
const response = await fakeRequest(
|
|
`${meta.route}?q=${users[0].data.username}`,
|
|
{
|
|
headers: {
|
|
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
|
},
|
|
},
|
|
);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
const data = (await response.json()) as ApiAccount[];
|
|
expect(data).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
id: users[0].id,
|
|
username: users[0].data.username,
|
|
display_name: users[0].data.displayName,
|
|
avatar: expect.any(String),
|
|
header: expect.any(String),
|
|
}),
|
|
]),
|
|
);
|
|
});
|
|
});
|