From e0d1712c0122e3c8b7c1e55a7f21ca2ddb1344b3 Mon Sep 17 00:00:00 2001 From: jose-carlos-sousa <139002032+jose-carlos-sousa@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:21:18 +0000 Subject: [PATCH] testing numeric value in minduration --- test/end-to-end/offer.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/end-to-end/offer.js b/test/end-to-end/offer.js index a100ae9a..d5df1f56 100644 --- a/test/end-to-end/offer.js +++ b/test/end-to-end/offer.js @@ -232,13 +232,6 @@ describe("Offer endpoint tests", () => { FieldValidatorTester.mustBeFuture(); FieldValidatorTester.mustBeAfter("publishDate"); }); - describe("jobMinDuration", () => { - const FieldValidatorTester = BodyValidatorTester("jobMinDuration"); - if (BodyValidatorTester("jobType") !== "FREELANCE") { - FieldValidatorTester.isRequired(); - FieldValidatorTester.mustBeNumber(); - } - }); describe("jobMaxDuration", () => { const FieldValidatorTester = BodyValidatorTester("jobMaxDuration"); FieldValidatorTester.isRequired(); @@ -707,6 +700,19 @@ describe("Offer endpoint tests", () => { expect(res.status).toBe(HTTPStatus.UNPROCESSABLE_ENTITY); }); + test("should fail jobMinDuration isn't numeric value", async () => { + const offer_params = generateTestOffer({ + jobMaxDuration: 8, + jobMinDuration: "nonNumeric", + owner: test_company._id, + }); + const res = await request() + .post("/offers/new") + .send(withGodToken(offer_params)); + expect(res.status).toBe(HTTPStatus.UNPROCESSABLE_ENTITY); + }); + + test("should succeed if jobMaxDuration is greater than jobMinDuration", async () => { const offer_params = generateTestOffer({ jobMinDuration: 8,