diff --git a/.env b/.env index c886003a..59857deb 100644 --- a/.env +++ b/.env @@ -50,7 +50,7 @@ MAIL_FROM_PASSWORD= # Cloudinary API URL to save images CLOUDINARY_URL= -# Hostname of the application (where the webserver will be served) - without the trailing '/' +# Hostname of the application (where the webserver will be served) - without the trailing '/' WEBSERVER_HOST=https://localhost:8087 # Path to save file uploads, the path must be relative to the root of the project - Defaults to static diff --git a/test/end-to-end/offer.js b/test/end-to-end/offer.js index 373e102d..fba8d3a3 100644 --- a/test/end-to-end/offer.js +++ b/test/end-to-end/offer.js @@ -234,7 +234,7 @@ describe("Offer endpoint tests", () => { }); describe("jobMinDuration", () => { const FieldValidatorTester = BodyValidatorTester("jobMinDuration"); - if (BodyValidatorTester("jobType") !== "freelance") { + if (BodyValidatorTester("jobType") !== "FREELANCE") { FieldValidatorTester.isRequired(); FieldValidatorTester.mustBeNumber(); } @@ -680,9 +680,21 @@ describe("Offer endpoint tests", () => { }); describe("Job Duration", () => { - test("should fail if jobMinDuration is greater than jobMaxDuration", async () => { + test("should not fail if jobMinDuration doesn't exist in freelance offer", async () => { + const offer_params = generateTestOffer({ + jobType: "FREELANCE", + jobMaxDuration: 8, + owner: test_company._id, + }); + + const res = await request() + .post("/offers/new") + .send(withGodToken(offer_params)); + expect(res.status).toBe(HTTPStatus.OK); + }); + + test("should not fail if jobMinDuration doesn't exist in freelance offer", async () => { const offer_params = generateTestOffer({ - jobMinDuration: 10, jobMaxDuration: 8, owner: test_company._id, }); @@ -690,12 +702,19 @@ describe("Offer endpoint tests", () => { const res = await request() .post("/offers/new") .send(withGodToken(offer_params)); + expect(res.status).toBe(HTTPStatus.OK); + }); + test("should fail if jobMinDuration doesn't exist in any offer besides freelance", async () => { + const offer_params = generateTestOffer({ + jobMinDuration: 10, + jobMaxDuration: 8, + owner: test_company._id, + }); + const res = await request() + .post("/offers/new") + .send(withGodToken(offer_params)); expect(res.status).toBe(HTTPStatus.UNPROCESSABLE_ENTITY); - expect(res.body).toHaveProperty("error_code", ErrorTypes.VALIDATION_ERROR); - expect(res.body).toHaveProperty("errors"); - expect(res.body.errors[0]).toHaveProperty("param", "jobMaxDuration"); - expect(res.body.errors[0]).toHaveProperty("msg", ValidationReasons.MUST_BE_GREATER_THAN_OR_EQUAL_TO("jobMinDuration")); }); test("should succeed if jobMaxDuration is greater than jobMinDuration", async () => {