I am working on a Nestjs application, and i would like to make a unit test for the following middleware:
@Injectable()
export class LocaleMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: () => void) {
if (!req.headers['accept-language'] || !(req.headers['accept-language']! in LocaleEnum)) {
req.headers['accept-language'] = LocaleEnum.en;
}
next();
}
}
How can mock the request and check that accept-language is assigned correctly ??