move to webapp

This commit is contained in:
m5r
2021-07-18 23:32:45 +08:00
parent 61c23ec9a7
commit a989125e6e
167 changed files with 26607 additions and 24066 deletions

View File

@ -0,0 +1,30 @@
import type { NextApiHandler } from "next";
import { withApiAuthRequired } from "../session-helpers";
import { callApiHandler } from "../../jest/helpers";
describe("session-helpers", () => {
describe("withApiAuthRequired", () => {
const basicHandler: NextApiHandler = (req, res) =>
res.status(200).end();
test("responds 401 to unauthenticated GET", async () => {
const withAuthHandler = withApiAuthRequired(basicHandler);
const { status } = await callApiHandler(withAuthHandler, {
method: "GET",
});
expect(status).toBe(401);
});
test("responds 200 to authenticated GET", async () => {
const withAuthHandler = withApiAuthRequired(basicHandler);
const { status } = await callApiHandler(withAuthHandler, {
method: "GET",
authentication: "auth0",
});
expect(status).toBe(200);
});
});
});