Skip to content

Commit b0897ad

Browse files
committed
Merge branch 'main' into giorgos
2 parents bd88f6a + 4d46138 commit b0897ad

15 files changed

Lines changed: 1343 additions & 825 deletions

controllers/LicensePlate.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@
33
var utils = require('../utils/writer.js');
44
var LicensePlate = require('../service/LicensePlateService');
55

6-
module.exports.modifyPlate = function modifyPlate (req, res, next, body) {
6+
// Function to handle modifying a license plate
7+
module.exports.modifyPlate = function modifyPlate (_,res,__,body) {
78
LicensePlate.modifyPlate(body)
89
.then(function (response) {
10+
// Write the response using the utility function
911
utils.writeJson(res, response);
1012
})
1113
.catch(function (response) {
14+
// Write the error response using the utility function
1215
utils.writeJson(res, response);
1316
});
1417
};
1518

16-
module.exports.registerPlate = function registerPlate (req, res, next, body) {
19+
//Function to handle registering a new license plate
20+
module.exports.registerPlate = function registerPlate (_,res,__,body) {
1721
LicensePlate.registerPlate(body)
1822
.then(function (response) {
23+
// Write the response using the utility function
1924
utils.writeJson(res, response);
2025
})
2126
.catch(function (response) {
27+
// Write the error response using the utility function
2228
utils.writeJson(res, response);
2329
});
2430
};

controllers/Payment.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
var utils = require('../utils/writer.js');
44
var Payment = require('../service/PaymentService');
55

6-
module.exports.makePayment = function makePayment (req, res, next, body) {
6+
//Function to handle making a payment
7+
module.exports.makePayment = function makePayment (_ ,res,__, body) {
78
Payment.makePayment(body)
89
.then(function (response) {
10+
// Write the response using the utility function
911
utils.writeJson(res, response);
1012
})
1113
.catch(function (response) {
14+
// Write the error response using the utility function
1215
utils.writeJson(res, response);
1316
});
14-
};
17+
};

controllers/Reservation.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,41 @@
33
var utils = require('../utils/writer.js');
44
var Reservation = require('../service/ReservationService');
55

6-
module.exports.deleteReservation = function deleteReservation (req, res, next, id) {
6+
// Function to handle deleting a reservation
7+
module.exports.deleteReservation = function deleteReservation (_, res, __, id) {
78
Reservation.deleteReservation(id)
89
.then(function (response) {
10+
// Write the response using the utility function
911
utils.writeJson(res, response);
1012
})
1113
.catch(function (response) {
14+
// Write the error response using the utility function
1215
utils.writeJson(res, response);
1316
});
1417
};
1518

16-
module.exports.makeReservation = function makeReservation (req, res, next, body) {
19+
//Function to handle making a reservation
20+
module.exports.makeReservation = function makeReservation (_, res,__, body) {
1721
Reservation.makeReservation(body)
1822
.then(function (response) {
23+
// Write the response using the utility function
1924
utils.writeJson(res, response);
2025
})
2126
.catch(function (response) {
27+
// Write the error response using the utility function
2228
utils.writeJson(res, response);
2329
});
2430
};
2531

26-
module.exports.modifyReservation = function modifyReservation (req, res, next, body, spotId, userId, startTime, duration, date, id) {
32+
//Function to handle modifying a reservation
33+
module.exports.modifyReservation = function modifyReservation (_, res, __, body, spotId, userId, startTime, duration, date, id) {
2734
Reservation.modifyReservation(body, spotId, userId, startTime, duration, date, id)
2835
.then(function (response) {
36+
// Write the response using the utility function
2937
utils.writeJson(res, response);
3038
})
3139
.catch(function (response) {
40+
// Write the error response using the utility function
3241
utils.writeJson(res, response);
3342
});
34-
};
43+
};

controllers/Spot.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,67 @@
33
var utils = require('../utils/writer.js');
44
var Spot = require('../service/SpotService');
55

6-
module.exports.createSpot = function createSpot (req, res, next, body) {
6+
//Function to handle creating a new spot
7+
module.exports.createSpot = function createSpot (_, res, __, body) {
78
Spot.createSpot(body)
89
.then(function (response) {
10+
// Write the response using the utility function
911
utils.writeJson(res, response);
1012
})
1113
.catch(function (response) {
14+
// Write the error response using the utility function
1215
utils.writeJson(res, response);
1316
});
1417
};
1518

16-
module.exports.getSpots = function getSpots (req, res, next) {
19+
//Function to handle retrieving all spots
20+
module.exports.getSpots = function getSpots (_, res,__){
1721
Spot.getSpots()
1822
.then(function (response) {
23+
// Write the response using the utility function
1924
utils.writeJson(res, response);
2025
})
2126
.catch(function (response) {
27+
// Write the error response using the utility function
2228
utils.writeJson(res, response);
2329
});
2430
};
2531

26-
module.exports.modifySpot = function modifySpot (req, res, next, body, address, type, charger, id) {
32+
//Function to handle modifying an existing parking spot
33+
module.exports.modifySpot = function modifySpot (_, res,__, body, address, type, charger, id) {
2734
Spot.modifySpot(body, address, type, charger, id)
2835
.then(function (response) {
36+
// Write the response using the utility function
2937
utils.writeJson(res, response);
3038
})
3139
.catch(function (response) {
40+
// Write the error response using the utility function
3241
utils.writeJson(res, response);
3342
});
3443
};
3544

36-
module.exports.removeSpot = function removeSpot (req, res, next, id) {
45+
// Function to handle removing a parking spot
46+
module.exports.removeSpot = function removeSpot (_, res, __, id) {
3747
Spot.removeSpot(id)
3848
.then(function (response) {
49+
// Write the response using the utility function
3950
utils.writeJson(res, response);
4051
})
4152
.catch(function (response) {
53+
// Write the error response using the utility function
4254
utils.writeJson(res, response);
4355
});
4456
};
4557

46-
module.exports.searchSpot = function searchSpot (req, res, next, address, type, charger) {
58+
//Function to handle searching for a parking spot
59+
module.exports.searchSpot = function searchSpot (_, res, __, address, type, charger) {
4760
Spot.searchSpot(address, type, charger)
4861
.then(function (response) {
62+
// Write the response using the utility function
4963
utils.writeJson(res, response);
5064
})
5165
.catch(function (response) {
66+
// Write the error response using the utility function
5267
utils.writeJson(res, response);
5368
});
54-
};
69+
};

controllers/SpotOwner.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
var utils = require('../utils/writer.js');
44
var SpotOwner = require('../service/SpotOwnerService');
55

6-
module.exports.addSpotOwner = function addSpotOwner (req, res, next, body) {
6+
//Function to handle adding a new spot owner
7+
module.exports.addSpotOwner = function addSpotOwner (_, res, __, body){
78
SpotOwner.addSpotOwner(body)
89
.then(function (response) {
10+
// Write the response using the utility function
911
utils.writeJson(res, response);
1012
})
1113
.catch(function (response) {
14+
// Write the error response using the utility function
1215
utils.writeJson(res, response);
1316
});
1417
};

cypress.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const { defineConfig } = require("cypress");
22

33
module.exports = defineConfig({
44
e2e: {
5-
setupNodeEvents(on, config) {
5+
setupNodeEvents(_ ,__) {
66
// implement node event listeners here
77
},
88
},
9-
});
9+
});

cypress/e2e/GET_spot.cy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
describe('GET /spot', () => {
22
beforeEach(() => {
3+
// Visit the Swagger UI page before each test
34
cy.visit('http://localhost:8080/docs')
45
})
56

67
it('Title exists', () => {
8+
//Check if the title contains the text 'Curbsprings API'
79
cy.get('.title').should('contain.text', 'Curbsprings API')
810
})
911

1012
it('Description exists', () => {
13+
// Check if the description includes the specified text
1114
cy.get('.description').should('include.text', 'API for managing parking spots, reservations, users, and payments.')
1215
})
1316

1417
it('All types of endpoints exists', () => {
18+
// Check if there are 5 endpoint tags in the Swagger UI
1519
cy.get('.opblock-tag').should('have.length', 5)
1620
})
1721

1822
it('Click on accordion', () => {
23+
// Click on the 'GET /spot' accordion to expand it
1924
cy.get('#operations-Spot-getSpots').click();
2025
})
2126

2227
it('Open accordion should include description', () => {
28+
// Check if the expanded accordion includes the specified text
2329
cy.get('#operations-Spot-getSpots')
2430
.click()
2531
.find('.opblock-description')

cypress/e2e/POST_payment.cy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
describe('POST /payment', () => {
22
beforeEach(() => {
3+
// Visit the Swagger UI before each test
34
cy.visit('http://localhost:8080/docs')
45
})
56

67
it('Title exists', () => {
8+
//Check if the title contains the text 'Curbsprings API'
79
cy.get('.title').should('contain.text', 'Curbsprings API')
810
})
911

1012
it('Description exists', () => {
13+
// Check if the description includes the specified text
1114
cy.get('.description').should('include.text', 'API for managing parking spots, reservations, users, and payments.')
1215
})
1316

1417
it('All types of endpoints exists', () => {
18+
// Check if there are 5 endpoint tags in the Swagger UI
1519
cy.get('.opblock-tag').should('have.length', 5)
1620
})
1721

1822
it('Click on accordion', () => {
23+
// Click on the 'POST /payment' accordion to expand it
1924
cy.get('#operations-Payment-makePayment').click();
2025
})
2126

2227
it('Open accordion should include description', () => {
28+
// Check if the expanded accordion includes the specified text
2329
cy.get('#operations-Payment-makePayment')
2430
.click()
2531
.find('.opblock-description')

0 commit comments

Comments
 (0)