import request from "supertest";
import app from "../src/app";
import { Server, IncomingMessage, ServerResponse } from "http";
import * as dotenv from "dotenv";

dotenv.config({path: '../../.env'})
const port = parseInt(process.env.BAR_PORT || '3000')

let serveur : Server<typeof IncomingMessage, typeof ServerResponse>

describe("Test the welcome path", () => {

    test("It should response the 200 code for GET method", done => {
        request(app)
        .get("/welcome")
        .then(response => {
            expect(response.statusCode).toBe(200);
            done();
        });
    });

    test("It should response the GET method with content", done => {
        const out = {hello:"world"};
        request(app)
        .get("/welcome")
        .then(response => {
            expect(response.text).toEqual(JSON.stringify(out))
            done();
        });
    });
});