Skip to content

Commit

Permalink
Record-service tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lauracc97 committed Apr 24, 2024
1 parent aa128ab commit dc6cf20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions recordhistory/record-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, () => {
Expand Down
6 changes: 6 additions & 0 deletions recordhistory/record-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
1 change: 0 additions & 1 deletion webapp/src/components/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const History = () => {
setHistoryData(result.data);

} catch (error) {
console.log(error.response.data.error);
}
};

Expand Down

0 comments on commit dc6cf20

Please sign in to comment.