import { Request, Response, NextFunction } from 'express';
import { emailsubscriptionController } from '../../routes/emailsubscription/postController';

describe('Email Subs page controller tests',() => {
    let req: Partial<Request>;
    let res: Partial<Response>
    let next: jest.MockedFunction<NextFunction> 
    beforeEach(()=>{
        req = {
            body: {},
            session: { formErrors: [],
                error: {},
            },
        } as unknown as Request
        res = {
            redirect: jest.fn(),
            status: jest.fn().mockReturnThis(),
            render: jest.fn().mockReturnThis()
        };
        next = jest.fn();

    })

    afterEach(() => {
        jest.clearAllMocks();
      });

    test('should move to success page when response is 200', async() => {
        await emailsubscriptionController(req as Request, res as Response , next, []);
        expect(next).toHaveBeenCalledTimes(1);
    })
})