diff --git a/package.json b/package.json index 7969d8e..206c0af 100644 --- a/package.json +++ b/package.json @@ -27,22 +27,22 @@ ], "license": "MIT", "dependencies": { - "axios": "^1.6.0", + "axios": "^1.6.2", "bcryptjs": "^2.4.3", "cors": "^2.8.5", "express": "^4.18.2", "express-basic-auth": "^1.2.1", - "express-rate-limit": "^7.1.3", + "express-rate-limit": "^7.1.4", "express-validator": "^7.0.1", "graphql": "^16.8.1", "graphql-http": "^1.22.0", "graphql-tag": "^2.12.6", - "helmet": "^7.0.0", + "helmet": "^7.1.0", "jsonwebtoken": "^9.0.2", "moment": "^2.29.4", - "mongodb": "^6.2.0", - "mongoose": "^8.0.0", - "pino": "^8.16.1", + "mongodb": "^6.3.0", + "mongoose": "^8.0.1", + "pino": "^8.16.2", "pino-pretty": "^10.2.3", "swagger-ui-express": "^5.0.0", "switcher-client": "^3.2.0", @@ -50,19 +50,19 @@ }, "devDependencies": { "@babel/cli": "^7.23.0", - "@babel/core": "^7.23.2", + "@babel/core": "^7.23.3", "@babel/node": "^7.22.19", - "@babel/preset-env": "^7.23.2", + "@babel/preset-env": "^7.23.3", "@babel/register": "^7.22.15", "babel-jest": "^29.7.0", "babel-polyfill": "^6.26.0", "env-cmd": "^10.1.0", - "eslint": "^8.52.0", + "eslint": "^8.54.0", "jest": "^29.7.0", "jest-sonar-reporter": "^2.0.0", "node-notifier": "^10.0.1", "nodemon": "^3.0.1", - "sinon": "^17.0.0", + "sinon": "^17.0.1", "supertest": "^6.3.3" }, "repository": { diff --git a/sonar-project.properties b/sonar-project.properties index af4a755..da67c2a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -9,7 +9,7 @@ sonar.javascript.lcov.reportPaths=coverage/lcov.info # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=src -sonar.exclusions=src/api-docs/**, src/app-server.js, src/helpers/timed-match/match-proc.js +sonar.exclusions=src/start.js, src/index.js, src/api-docs/**, src/app-server.js, src/helpers/timed-match/match-proc.js sonar.tests=tests sonar.language=js diff --git a/tests/app.test.js b/tests/app.test.js new file mode 100644 index 0000000..d5e1414 --- /dev/null +++ b/tests/app.test.js @@ -0,0 +1,38 @@ +import mongoose from 'mongoose'; +import app from '../src/app'; +import request from 'supertest'; + +afterAll(async () => { + await new Promise(resolve => setTimeout(resolve, 1000)); + await mongoose.disconnect(); +}); + +describe('Testing app [REST] ', () => { + test('APP_SUITE - Should return success on a health check request', async () => { + const req = await request(app) + .get('/check') + .expect(200); + + expect(req.statusCode).toBe(200); + expect(req.body.status).toEqual('UP'); + }); + + test('APP_SUITE - Should return success on a health check request with details', async () => { + const req = await request(app) + .get('/check?details=1') + .expect(200); + + expect(req.statusCode).toBe(200); + expect(req.body.status).toEqual('UP'); + expect(req.body.attributes).toBeDefined(); + }); + + test('APP_SUITE - Should return 404 - Operation not found', async () => { + const req = await request(app) + .get('/not-found') + .expect(404); + + expect(req.statusCode).toBe(404); + expect(req.body.error).toEqual('Operation not found'); + }); +});