32 lines
893 B
TypeScript
32 lines
893 B
TypeScript
import { describe, expect, it } from "bun:test";
|
|
|
|
import app from "~/index";
|
|
import { server } from "~/mocks";
|
|
|
|
server.listen();
|
|
|
|
describe('requests the "/title" route', () => {
|
|
it("with a valid id & token", async () => {
|
|
const response = await app.request("/title?id=10", {
|
|
headers: new Headers({ "x-anilist-token": "asd" }),
|
|
});
|
|
|
|
expect(response.json()).resolves.toMatchSnapshot();
|
|
expect(response.status).toBe(200);
|
|
});
|
|
|
|
it("with a valid id but no token", async () => {
|
|
const response = await app.request("/title?id=10");
|
|
|
|
expect(response.json()).resolves.toMatchSnapshot();
|
|
expect(response.status).toBe(200);
|
|
});
|
|
|
|
it("with an unknown title from all sources", async () => {
|
|
const response = await app.request("/title?id=-1");
|
|
|
|
expect(response.json()).resolves.toEqual({ success: false });
|
|
expect(response.status).toBe(404);
|
|
});
|
|
});
|