Skip to content

Commit

Permalink
changed end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-carlos-sousa committed Mar 5, 2024
1 parent cd3f02b commit 7ecca88
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 26 additions & 7 deletions test/end-to-end/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -680,22 +680,41 @@ 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,
});

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 () => {
Expand Down

0 comments on commit 7ecca88

Please sign in to comment.