import { Test, TestingModule } from '@nestjs/testing';
import { Response } from 'express';
import { AppController } from './app.controller';
import { AppService } from './app.service';

describe('AppController', () => {
  let appController: AppController;

  beforeEach(async () => {
    const app: TestingModule = await Test.createTestingModule({
      controllers: [AppController],
      providers: [
        {
          provide: AppService,
          useValue: {
            uploadFiles: jest.fn(),
          },
        },
      ],
    }).compile();

    appController = app.get<AppController>(AppController);
  });

  describe('root', () => {
    it('should return welcome message payload', () => {
      const json = jest.fn();
      const res = { json } as unknown as Response;

      appController.getHello(res);

      expect(json).toHaveBeenCalledWith({
        message: 'Wellcome to task management system',
      });
    });
  });
});
