Files
outline/server/routes/auth/index.test.ts
Tom Moor 1fbc000e03 chore: Reduce test boilerplate (#4300)
* chore: Reduce test boilerplate

* mo
2022-10-15 19:40:21 -07:00

34 lines
981 B
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").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").endsWith(collection.url)).toBeTruthy();
});
});