import supertest from 'supertest';
import 'jest-extended';
import app from '../../src/app';
import { superagent, serverAPI } from '../../src/utils/define';

const request = supertest(app);

import courseAllMockResponse from '../mocks/responses/course-all.json';
import scheduleAllMockResponse from '../mocks/responses/schedule-all.json';
import studentAllMockResponse from '../mocks/responses/student-all.json';
import studentGroupStudentMockResponse from '../mocks/responses/student-groupstudent.json';
import { CoursControlleur } from '../../src/controleurs/coursControleur';
import { DevoirControleur } from '../../src/controleurs/devoirControleur';

import mocker from 'superagent-mocker';
mocker.timeout = 50;
const superagentMock = mocker(superagent);

describe('/devoir', () => {

    const coursControlleur: CoursControlleur = new CoursControlleur();
    const devoirControleur: DevoirControleur = new DevoirControleur();
    
    beforeEach(async () => {
        superagentMock.get(`http://${serverAPI}/api/v3/course/all`, () => courseAllMockResponse);
        superagentMock.get(`http://${serverAPI}/api/v3/schedule/all`, () => scheduleAllMockResponse);
        superagentMock.get(`http://${serverAPI}/api/v3/student/all`, () => studentAllMockResponse);
        superagentMock.get(`http://${serverAPI}/api/v3/student/groupstudent`, () => studentGroupStudentMockResponse);
        await coursControlleur.init();
    });
    afterAll(() => {
        superagentMock.clearRoutes();
    });

  it('devrait avoir un contenu HTML', async () => {
    const response = await request.get('/devoir');
    expect(response.status).toBe(200);
    expect(response.type).toBe("text/html");
  });
});






