2024-05-06 21:20:29 +02:00
|
|
|
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", () => {
|
|
|
|
|
2024-05-19 11:38:38 +02:00
|
|
|
test("It should response the 200 code for GET method", done => {
|
2024-05-06 21:20:29 +02:00
|
|
|
request(app)
|
|
|
|
.get("/welcome")
|
|
|
|
.then(response => {
|
|
|
|
expect(response.statusCode).toBe(200);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-05-19 11:38:38 +02:00
|
|
|
test("It should response the GET method with content", done => {
|
2024-05-06 21:20:29 +02:00
|
|
|
const out = {hello:"world"};
|
|
|
|
request(app)
|
|
|
|
.get("/welcome")
|
|
|
|
.then(response => {
|
|
|
|
expect(response.text).toEqual(JSON.stringify(out))
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|