ncc-prototype-email-alerts-sub
Version:
Northumberland Council Front End Email Alerts Subscription Prototype
34 lines (22 loc) • 771 B
text/typescript
import navigator from '../../libs/navigator';
import { Request, Response, NextFunction } from 'express';
const res = { redirect: jest.fn() } as unknown as Response;
const req = {
originalUrl: ''
} as unknown as Request
const next = jest.fn() as NextFunction;
beforeEach(() => {
jest.clearAllMocks();
});
describe('Navigator tests', () => {
test('postcode page proceeds to address selection', () => {
req.originalUrl = '/postcode';
navigator(req, res, next);
expect(res.redirect).toHaveBeenCalledWith('/address-select');
});
test('empty page param redirects to root', () => {
req.originalUrl = '';
navigator(req, res, next);
expect(res.redirect).toHaveBeenCalledWith('/');
});
});