Compare commits

...

2 Commits

Author SHA1 Message Date
adc63a097d fix test
All checks were successful
Build Docker Image Front / run (push) Successful in 23s
Build Docker Image Back / run (push) Successful in 1m4s
Build Docker Image Front / run (pull_request) Successful in 22s
Build Docker Image Back / run (pull_request) Successful in 21s
JsDocs / coverage (pull_request) Successful in 33s
Test and coverage / coverage (pull_request) Successful in 35s
2024-05-06 19:44:15 +02:00
75051827f7 fix dev and rename to welcome 2024-05-06 19:44:08 +02:00
3 changed files with 14 additions and 10 deletions

View File

@ -4,7 +4,7 @@
"build": "rimraf dist && npx tsc",
"start": "node dist/src/server.js",
"predev": "npm run build",
"dev": "npx tsc -w & nodemon dist/server.js",
"dev": "npx tsc -w & nodemon dist/src/server.js",
"docs": "jsdoc -c jsdoc.json",
"test": "jest"
},

View File

@ -9,14 +9,15 @@ const app = express();
/**
* Handle GET request for homepage route ('/').
* Send back a simple text response.
* Send back a simple json response.
* @param {express.Request} req - HTTP Request object.
* @param {express.Response} res - HTTP Response object.
*/
function getRoot(req: express.Request, res: express.Response) {
res.send("hello world from dev");
function getWelcome(req: express.Request, res: express.Response) {
const out = {hello:"world"};
res.send(out);
}
app.get("/", getRoot);
app.get("/welcome", getWelcome);
export default app;

View File

@ -1,12 +1,14 @@
import request from "supertest";
import app from "../src/app";
import { Server, IncomingMessage, ServerResponse } from "http";
import * as dotenv from "dotenv";
const port = 3000;
dotenv.config({path: '../../.env'})
const port = parseInt(process.env.BAR_PORT || '3000')
let serveur : Server<typeof IncomingMessage, typeof ServerResponse>
describe("Test the root path", () => {
describe("Test the welcome path", () => {
beforeEach(() => {
serveur = app.listen(port, () =>{
@ -20,7 +22,7 @@ describe("Test the root path", () => {
test("It should response the GET method", done => {
request(app)
.get("/")
.get("/welcome")
.then(response => {
expect(response.statusCode).toBe(200);
done();
@ -28,10 +30,11 @@ describe("Test the root path", () => {
});
test("It should response the GET method", done => {
const out = {hello:"world"};
request(app)
.get("/")
.get("/welcome")
.then(response => {
expect(response.text).toEqual("hello world from dev")
expect(response.text).toEqual(JSON.stringify(out))
done();
});
});