Added: note in backend
This commit is contained in:
parent
c9b8246218
commit
c6b3efad4e
@ -28,6 +28,11 @@ const schema = new Schema<IReview | any>(
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
beer_id: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
@ -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<typeof add>, 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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user