mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-11-02 11:33:21 +01:00
2135c6b9f1
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
|
|
import { getAllInputs, getAllTargets } from "../../src/converters/main";
|
|
import { createUser, request } from "./helpers/app";
|
|
|
|
describe("GET /converters", () => {
|
|
test("redirects to the login page without a session", async () => {
|
|
const response = await request("/converters", { headers: { accept: "text/html" } });
|
|
|
|
expect(response.status).toBe(302);
|
|
expect(response.headers.get("location")).toBe("/login");
|
|
});
|
|
|
|
test("lists every converter with the number of inputs and targets", async () => {
|
|
const user = await createUser();
|
|
|
|
const body = await (await request("/converters", { cookies: { auth: user.token } })).text();
|
|
|
|
for (const [converter, targets] of Object.entries(getAllTargets())) {
|
|
expect(body).toContain(
|
|
`<td>${converter}</td><td>Count: ${getAllInputs(converter).length}<ul>`,
|
|
);
|
|
expect(body).toContain(`Count: ${targets.length}<ul>`);
|
|
}
|
|
});
|
|
|
|
test("lists the inputs and targets of a converter", async () => {
|
|
const user = await createUser();
|
|
|
|
const body = await (await request("/converters", { cookies: { auth: user.token } })).text();
|
|
|
|
expect(body).toContain(
|
|
"<td>vcf</td><td>Count: 1<ul><li>vcf</li></ul></td><td>Count: 1<ul><li>csv</li></ul></td>",
|
|
);
|
|
});
|
|
});
|