Skip to content
Snippets Groups Projects
Commit b8c7afc5 authored by benjamin.anthonio's avatar benjamin.anthonio
Browse files

Merge branch 'write_tests'

parents 7cd66b96 9ede0c6f
No related branches found
No related tags found
No related merge requests found
module.exports = {
transform: {'^.+\\.ts?$': 'ts-jest'},
testEnvironment: 'node',
testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
};
\ No newline at end of file
......@@ -19,7 +19,8 @@
"database:deploy:prod": "npm run database:migrate:deploy && npm run database:seed:prod",
"start:dev": "npm run prisma:generate && npx dotenvx run -- npx nodemon src/app.ts",
"start:prod": "npm run build && npx dotenvx run -- NODE_ENV=production npx node dist/src/app.js",
"clean": "rm -R dist/*"
"clean": "rm -R dist/*",
"test": "jest"
},
"prisma": {
"seed": "node dist/prisma/seed"
......@@ -45,14 +46,17 @@
"@types/bcryptjs": "^2.4.6",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.14",
"@types/jsonwebtoken": "^9.0.6",
"@types/morgan": "^1.9.9",
"@types/multer": "^1.4.11",
"@types/node": "^20.12.7",
"jest": "^29.7.0",
"node": "^20.12.2",
"nodemon": "^3.1.0",
"npm": "^10.5.2",
"prisma": "^6.3.1",
"ts-jest": "^29.2.6",
"ts-node": "^10.9.2",
"tsx": "^4.7.2",
"typescript": "^5.4.5"
......
......@@ -101,6 +101,11 @@ export class Server {
this.server = http.createServer(this.backend);
}
public get app() {
return this.backend;
}
run() {
this.server.listen(Config.api.port, '0.0.0.0', () => {
const {
......
import { describe } from 'node:test';
import { expect, test } from '@jest/globals';
import { calcNoteBaremeFed } from '../src/calcFunctions';
describe('testing index file', () => {
test('empty string should result in zero', () => {
expect(calcNoteBaremeFed(50, 50)).toBe(6);
expect(calcNoteBaremeFed(0, 50)).toBe(1);
expect(calcNoteBaremeFed(0, 50)).not.toBe(0);
});
});
\ No newline at end of file
module.exports = {
transform: {'^.+\\.ts?$': 'ts-jest'},
testEnvironment: 'node',
testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
};
\ No newline at end of file
{
"name": "testsendpoints",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"ts-jest": "^29.2.6"
},
"dependencies": {
"@types/supertest": "^6.0.2",
"supertest": "^7.0.0"
}
}
import { expect, jest } from '@jest/globals';
import request from 'supertest';
import { describe, it } from 'node:test';
import Server from '../../microservices/navigation_qcm/src/express/Server';
const server = new Server();
describe('POST /join', () => {
it('manque des parametres', async () => {
const response = await request(server.app).post('/join').send({});
expect(response.status).toBe(400);
// expect(response.body).toEqual({ message: 'Hello, world!' });
});
it('nombre de questions QCM', async () => {
const response = await request(server.app).post('/join').send({});
expect(response.status).toBe(401);
});
it('code accès QCM', async () => {
const response = await request(server.app).post('/join').send({});
expect(response.status).toBe(401);
});
it('existance du QCM', async () => {
const response = await request(server.app).post('/join').send({});
expect(response.status).toBe(404);
});
});
describe('GET /reponseCorrect/:QCM_ID', () => {
// it('manque des parametres', async () => {
// const QCM_ID = 1;
// jest.spyOn(db.question, 'findMany').mockResolvedValue([
// {
// idQCM: QCM_ID,
// numeric: null,
// choix: [
// { idChoix: 1, isCorrect: true },
// { idChoix: 2, isCorrect: false }
// ]
// },
// {
// idQCM: QCM_ID,
// numeric: 5,
// choix: []
// }
// ]);
// const response = await request(server.app).post('/reponseCorrect/${QCM_ID}').send({});
// expect(response.status).toBe(400);
// });
// it('nombre de questions QCM', async () => {
// const response = await request(server.app).post('/reponseCorrect/${QCM_ID}').send({});
// expect(response.status).toBe(401);
// });
// it('code accès QCM', async () => {
// const response = await request(server.app).post('/reponseCorrect/${QCM_ID}').send({});
// expect(response.status).toBe(401);
// });
// it('existance du QCM', async () => {
// const response = await request(server.app).post('/reponseCorrect/${QCM_ID}').send({});
// expect(response.status).toBe(404);
// });
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment