Fixing more tests · hackmcgill/hackerAPI@ce49ad1 · GitHub
Skip to content

Commit ce49ad1

Browse files
Fixing more tests
1 parent bb1e727 commit ce49ad1

5 files changed

Lines changed: 26 additions & 20 deletions

File tree

‎controllers/hacker.controller.js‎

Lines changed: 1 addition & 0 deletions

‎middlewares/hacker.middleware.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const Constants = {
2626
* @description Delete the req.body.id that was added by the validation of route parameter.
2727
*/
2828
function parsePatch(req, res, next) {
29+
console.log(req.body);
2930
delete req.body.id;
3031
return next();
3132
}

‎middlewares/validators/validator.helper.js‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function integerValidator(
3333
const value = setProperValidationChainBuilder(
3434
fieldLocation,
3535
fieldname,
36-
"invalid integer"
36+
"Invalid integer"
3737
);
3838

3939
if (optional) {
@@ -74,7 +74,7 @@ function mongoIdValidator(fieldLocation, fieldname, optional = true) {
7474
const mongoId = setProperValidationChainBuilder(
7575
fieldLocation,
7676
fieldname,
77-
"invalid mongoID"
77+
"Invalid mongoID"
7878
);
7979

8080
if (optional) {
@@ -102,7 +102,7 @@ function mongoIdArrayValidator(fieldLocation, fieldname, optional = true) {
102102
const arr = setProperValidationChainBuilder(
103103
fieldLocation,
104104
fieldname,
105-
"invalid mongoID array"
105+
"Invalid mongoID array"
106106
);
107107

108108
if (optional) {
@@ -135,7 +135,7 @@ function booleanValidator(
135135
const booleanField = setProperValidationChainBuilder(
136136
fieldLocation,
137137
fieldname,
138-
"invalid boolean"
138+
"Invalid boolean"
139139
);
140140

141141
if (optional) {
@@ -176,7 +176,7 @@ function asciiValidator(fieldLocation, fieldname, optional = true) {
176176
const name = setProperValidationChainBuilder(
177177
fieldLocation,
178178
fieldname,
179-
"invalid name"
179+
"Invalid name"
180180
);
181181
if (optional) {
182182
return name
@@ -240,7 +240,7 @@ function regexValidator(
240240
const match = setProperValidationChainBuilder(
241241
fieldLocation,
242242
fieldname,
243-
"invalid name"
243+
"Invalid name"
244244
);
245245

246246
if (optional) {
@@ -269,7 +269,7 @@ function alphaValidator(fieldLocation, fieldname, optional = true) {
269269
const name = setProperValidationChainBuilder(
270270
fieldLocation,
271271
fieldname,
272-
"invalid alpha string"
272+
"Invalid alpha string"
273273
);
274274
if (optional) {
275275
return name
@@ -296,7 +296,7 @@ function alphaArrayValidator(fieldLocation, fieldname, optional = true) {
296296
const name = setProperValidationChainBuilder(
297297
fieldLocation,
298298
fieldname,
299-
"invalid alpha array"
299+
"Invalid alpha array"
300300
);
301301

302302
if (optional) {
@@ -346,7 +346,7 @@ function passwordValidator(fieldLocation, fieldname, optional = true) {
346346
const password = setProperValidationChainBuilder(
347347
fieldLocation,
348348
fieldname,
349-
"invalid password"
349+
"Invalid password"
350350
);
351351
if (optional) {
352352
return password
@@ -378,7 +378,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
378378
const application = setProperValidationChainBuilder(
379379
fieldLocation,
380380
fieldname,
381-
"invalid application"
381+
"Invalid application"
382382
);
383383
//helper object to iterate through the items in the application and track which items are not valid.
384384
const hasValid = {
@@ -707,7 +707,7 @@ function dateValidator(fieldLocation, fieldname, optional = true) {
707707
const date = setProperValidationChainBuilder(
708708
fieldLocation,
709709
fieldname,
710-
"invalid date"
710+
"Invalid date"
711711
);
712712
if (optional) {
713713
return date
@@ -747,7 +747,7 @@ function phoneNumberValidator(fieldLocation, fieldname, optional = true) {
747747
const number = setProperValidationChainBuilder(
748748
fieldLocation,
749749
fieldname,
750-
"invalid phone number"
750+
"Invalid phone number"
751751
);
752752
if (optional) {
753753
return number
@@ -875,7 +875,7 @@ function checkEnum(value, enums) {
875875
*
876876
* @param {"query" | "body" | "header" | "param"} fieldLocation the location where the field should be found
877877
* @param {string} fieldname name of the field that needs to be validated.
878-
* @param {*} errorString the string that is sent back to the user if the field is invalid
878+
* @param {*} errorString the string that is sent back to the user if the field is Invalid
879879
*/
880880
function setProperValidationChainBuilder(
881881
fieldLocation,

‎services/hacker.service.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function updateOne(id, hackerDetails) {
3535
const query = {
3636
_id: id
3737
};
38+
console.log(query, hackerDetails);
3839

3940
return Hacker.findOneAndUpdate(
4041
query,
@@ -195,9 +196,8 @@ function getStats(hackers) {
195196
? stats.graduationYear[hacker.application.general.graduationYear] +
196197
1
197198
: 1;
198-
199199
for (const dietaryRestrictions of hacker.application.accommodation
200-
.dietaryRestrictions.dietaryRestrictions) {
200+
.dietaryRestrictions) {
201201
stats.dietaryRestrictions[dietaryRestrictions] = stats
202202
.dietaryRestrictions[dietaryRestrictions]
203203
? stats.dietaryRestrictions[dietaryRestrictions] + 1

‎tests/hacker.test.js‎

Lines changed: 9 additions & 5 deletions

0 commit comments

Comments
 (0)