diff --git a/recordhistory/record-service.js b/recordhistory/record-service.js index afde2851..53fc4d40 100644 --- a/recordhistory/record-service.js +++ b/recordhistory/record-service.js @@ -2,7 +2,7 @@ const express = require('express'); const mongoose = require('mongoose'); const bodyParser = require('body-parser'); -const Record = require('./record-model') +const Record = require('./record-model'); const app = express(); const port = 8003; @@ -49,7 +49,7 @@ app.post('/addRecord', async (req, res) => { res.json(records); } catch (error) { - res.status(400).json({ error: error.message }); + }}); const server = app.listen(port, () => { diff --git a/recordhistory/record-service.test.js b/recordhistory/record-service.test.js index a6d21253..f841cf08 100644 --- a/recordhistory/record-service.test.js +++ b/recordhistory/record-service.test.js @@ -64,4 +64,10 @@ describe('Record Service', () => { expect(response.body[0]).toHaveProperty('user_id', 'testuser'); expect(response.body[1]).toHaveProperty('user_id', 'testuser'); }); + + it('Should respond 400 error due to sending an empty body to the addRecords', async () => { + const response = await request(app).post('/addRecord').send({}); + expect(response.statusCode).toBe(400); + expect(response.body).toHaveProperty('error'); + }); }); diff --git a/webapp/src/components/History.js b/webapp/src/components/History.js index 0bf8acfd..b7c9463c 100644 --- a/webapp/src/components/History.js +++ b/webapp/src/components/History.js @@ -22,7 +22,6 @@ const History = () => { setHistoryData(result.data); } catch (error) { - console.log(error.response.data.error); } };