Files
outline/server/routes/auth/index.test.ts
Apoorv Mishra 67b1fe5514 Local file storage (#5763)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
2023-09-20 15:12:03 -07:00

36 lines
1.1 KiB
TypeScript

import { buildUser, buildCollection } from "@server/test/factories";
import { getTestServer } from "@server/test/support";
const server = getTestServer();
describe("auth/redirect", () => {
it("should redirect to home", async () => {
const user = await buildUser();
const res = await server.get(
`/auth/redirect?token=${user.getTransferToken()}`,
{
redirect: "manual",
}
);
expect(res.status).toEqual(302);
expect(res.headers.get("location")).not.toBeNull();
expect(res.headers.get("location")!.endsWith("/home")).toBeTruthy();
});
it("should redirect to first collection", async () => {
const collection = await buildCollection();
const user = await buildUser({
teamId: collection.teamId,
});
const res = await server.get(
`/auth/redirect?token=${user.getTransferToken()}`,
{
redirect: "manual",
}
);
expect(res.status).toEqual(302);
expect(res.headers.get("location")).not.toBeNull();
expect(res.headers.get("location")!.endsWith(collection.url)).toBeTruthy();
});
});