import { csrfCheckMiddleware } from './csrf'; // this is a middleware i wrote with `createMiddleware`
it('throws a 401 Unauthorized error if no Authorization header is present', async () => {
vi.spyOn(serverUtils, 'getHeaders').mockReturnValue({});
const next = vi.fn();
await expect(
csrfCheckMiddleware({ next }) //this is not callable :(
).rejects.toThrow();
expect(next).not.toHaveBeenCalled();
});
import { csrfCheckMiddleware } from './csrf'; // this is a middleware i wrote with `createMiddleware`
it('throws a 401 Unauthorized error if no Authorization header is present', async () => {
vi.spyOn(serverUtils, 'getHeaders').mockReturnValue({});
const next = vi.fn();
await expect(
csrfCheckMiddleware({ next }) //this is not callable :(
).rejects.toThrow();
expect(next).not.toHaveBeenCalled();
});