Rename directory from email-server-worker to email-worker for clarity and brevity. Update all references in CLAUDE.md documentation.
33 lines
841 B
TypeScript
33 lines
841 B
TypeScript
import { Request, Response, NextFunction } from 'express';
|
|
import { NgitLocals } from "../../src/types/NgitLocals";
|
|
|
|
interface IMockHttpContext {
|
|
reqPath?:string
|
|
headersSent?:boolean
|
|
writableEnded?:boolean
|
|
method?:string
|
|
}
|
|
|
|
export const mockHttpContext = ({reqPath="/", headersSent=false, writableEnded=false, method="GET"}:IMockHttpContext|undefined = {}) => {
|
|
const req = {
|
|
path:reqPath,
|
|
method,
|
|
url:`https://localhost${reqPath}`,
|
|
params: {},
|
|
} as unknown as Request;
|
|
|
|
const res = {
|
|
end: jest.fn(),
|
|
status: jest.fn(),
|
|
setHeader: jest.fn(),
|
|
locals: {
|
|
stopPrometheusTimer: jest.fn(),
|
|
} as unknown as NgitLocals,
|
|
headersSent,
|
|
writableEnded,
|
|
} as unknown as Response;
|
|
|
|
const next:NextFunction = jest.fn();
|
|
|
|
return({req,res,next})
|
|
} |