Added and updated comments throughout entire project
This commit is contained in:
+24
-4
@@ -10,13 +10,14 @@ app.use(express.urlencoded({ extended: false }))
|
||||
app.use("/", routes)
|
||||
|
||||
/**
|
||||
* Testing post message logic
|
||||
* Testing post message logic and response status codes
|
||||
*/
|
||||
describe('POST /msg/:id', function () {
|
||||
const data = {
|
||||
message: "test",
|
||||
}
|
||||
|
||||
// Send basic message with id 1
|
||||
it('respond with 201 created', function (done) {
|
||||
request(app)
|
||||
.post('/msg/1')
|
||||
@@ -27,6 +28,7 @@ describe('POST /msg/:id', function () {
|
||||
.expect(201, done);
|
||||
});
|
||||
|
||||
// Tries to send a message that already exists
|
||||
it('respond with 400 not posted', function (done) {
|
||||
request(app)
|
||||
.post('/msg/1')
|
||||
@@ -39,6 +41,7 @@ describe('POST /msg/:id', function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Tries to send a message with an id that won't work
|
||||
it('respond with 404 error', function (done) {
|
||||
request(app)
|
||||
.post('/msg/idisnonexisting')
|
||||
@@ -53,9 +56,11 @@ describe('POST /msg/:id', function () {
|
||||
});
|
||||
|
||||
/**
|
||||
* Testing get message logic
|
||||
* Testing get message logic and response status codes
|
||||
*/
|
||||
describe('GET /msg', function () {
|
||||
|
||||
// Get info of entire database
|
||||
it('respond with 200 info recieved', function (done) {
|
||||
request(app)
|
||||
.get('/msg')
|
||||
@@ -66,6 +71,8 @@ describe('GET /msg', function () {
|
||||
});
|
||||
|
||||
describe('GET /msg/:id', function () {
|
||||
|
||||
//Get info of a message with id 1
|
||||
it('respond with 200 info recieved for one message', function (done) {
|
||||
request(app)
|
||||
.get('/msg/1')
|
||||
@@ -74,6 +81,7 @@ describe('GET /msg/:id', function () {
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
// Get info of a message that doesnt exist
|
||||
it('respond with 400 message not found', function (done) {
|
||||
request(app)
|
||||
.get('/msg/2')
|
||||
@@ -86,6 +94,7 @@ describe('GET /msg/:id', function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Get info of a message with an id that won't work
|
||||
it('respond with 404 error', function (done) {
|
||||
request(app)
|
||||
.get('/msg/idisnonexisting')
|
||||
@@ -100,9 +109,11 @@ describe('GET /msg/:id', function () {
|
||||
});
|
||||
|
||||
/**
|
||||
* Testing put message logic
|
||||
* Testing update message logic and response status codes
|
||||
*/
|
||||
describe('PUT /msg/:id', function () {
|
||||
|
||||
// Update the info of a message with id 1
|
||||
it('respond with 201 message updated', function (done) {
|
||||
request(app)
|
||||
.put('/msg/1')
|
||||
@@ -111,6 +122,7 @@ describe('PUT /msg/:id', function () {
|
||||
.expect(201, done);
|
||||
});
|
||||
|
||||
// Update the info of a message that doesn't exist
|
||||
it('respond with 400 message not found', function (done) {
|
||||
request(app)
|
||||
.put('/msg/2')
|
||||
@@ -123,6 +135,8 @@ describe('PUT /msg/:id', function () {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Update the info of a message with an id that won't work
|
||||
it('respond with 404 error', function (done) {
|
||||
request(app)
|
||||
.put('/msg/idisnonexisting')
|
||||
@@ -137,9 +151,11 @@ describe('PUT /msg/:id', function () {
|
||||
});
|
||||
|
||||
/**
|
||||
* Testing delete message logic
|
||||
* Testing delete message logic and response status codes
|
||||
*/
|
||||
describe('DELETE /msg/:id', function () {
|
||||
|
||||
// Delete a message with id of 1
|
||||
it('respond with 200 single message deleted', function (done) {
|
||||
request(app)
|
||||
.delete('/msg/1')
|
||||
@@ -148,6 +164,7 @@ describe('DELETE /msg/:id', function () {
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
// Delete a message that doesn't exist
|
||||
it('respond with 400 message not found', function (done) {
|
||||
request(app)
|
||||
.delete('/msg/1')
|
||||
@@ -160,6 +177,7 @@ describe('DELETE /msg/:id', function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Delete a message with an id that won't work
|
||||
it('respond with 404 error', function (done) {
|
||||
request(app)
|
||||
.delete('/msg/idisnonexisting')
|
||||
@@ -174,6 +192,8 @@ describe('DELETE /msg/:id', function () {
|
||||
});
|
||||
|
||||
describe('DELETE /msg', function () {
|
||||
|
||||
// Delete all messages within database
|
||||
it('respond with 200 all messages deleted', function (done) {
|
||||
request(app)
|
||||
.delete('/msg')
|
||||
|
||||
Reference in New Issue
Block a user