diff --git a/api/src/models/Review.ts b/api/src/models/Review.ts index 7c39149..36671b5 100644 --- a/api/src/models/Review.ts +++ b/api/src/models/Review.ts @@ -28,6 +28,11 @@ const schema = new Schema( type: Boolean, required: true, }, + note: { + type: String, + required: false, + default: "" + }, beer_id: { type: String, required: true, diff --git a/api/src/validators/reviewValidator.ts b/api/src/validators/reviewValidator.ts index 03fe14c..213020f 100644 --- a/api/src/validators/reviewValidator.ts +++ b/api/src/validators/reviewValidator.ts @@ -20,7 +20,8 @@ export const add = yup.object({ packaging: yup.number().min(1).max(5).required(), sourness: yup.boolean().required(), would_again: yup.boolean().required(), - user_id: yup.string().notRequired() + user_id: yup.string().notRequired(), + note: yup.string().notRequired() }); export interface IReview extends yup.InferType, mongooseAddition {} export const addExam: IReview = { @@ -31,6 +32,7 @@ export const addExam: IReview = { packaging: 3, sourness: false, would_again: true, + note: "Pretty good beer" }; // Remove diff --git a/api/tests/review.test.ts b/api/tests/review.test.ts index 68801f2..f504aac 100644 --- a/api/tests/review.test.ts +++ b/api/tests/review.test.ts @@ -73,6 +73,15 @@ describe("POST /api/v1/review/add", () => { expect(res.statusCode).toBe(400); }); + test("should drop 201 (missing note)", async () => { + const jwt = await login(); + const body: any = { ...addExam }; + delete body.note; + const res = await request.post(url).set("Cookie", jwt).send(body); + + expect(res.statusCode).toBe(201); + }) + test("should drop 201", async () => { const jwt = await login(); const res = await request.post(url).set("Cookie", jwt).send(addExam);