Skip to content

Commit 2577513

Browse files
changed end-to-end tests
1 parent cd3f02b commit 2577513

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ MAIL_FROM_PASSWORD=
5050
# Cloudinary API URL to save images
5151
CLOUDINARY_URL=
5252

53-
# Hostname of the application (where the webserver will be served) - without the trailing '/'
53+
# Hostname of the application (where the webserver will be served) - without the trailing '/'
5454
WEBSERVER_HOST=https://localhost:8087
5555

5656
# Path to save file uploads, the path must be relative to the root of the project - Defaults to static

test/end-to-end/offer.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ describe("Offer endpoint tests", () => {
234234
});
235235
describe("jobMinDuration", () => {
236236
const FieldValidatorTester = BodyValidatorTester("jobMinDuration");
237-
if (BodyValidatorTester("jobType") !== "freelance") {
237+
if (BodyValidatorTester("jobType") !== "FREELANCE") {
238238
FieldValidatorTester.isRequired();
239239
FieldValidatorTester.mustBeNumber();
240240
}
@@ -680,22 +680,31 @@ describe("Offer endpoint tests", () => {
680680
});
681681

682682
describe("Job Duration", () => {
683-
test("should fail if jobMinDuration is greater than jobMaxDuration", async () => {
683+
684+
test("should succeed if jobMinDuration doesn't exist in freelance offer", async () => {
684685
const offer_params = generateTestOffer({
685-
jobMinDuration: 10,
686+
jobType: "FREELANCE",
686687
jobMaxDuration: 8,
688+
jobMinDuration: null,
687689
owner: test_company._id,
688690
});
689-
690691
const res = await request()
691692
.post("/offers/new")
692693
.send(withGodToken(offer_params));
694+
expect(res.status).toBe(HTTPStatus.OK);
695+
});
696+
697+
test("should fail if jobMinDuration doesn't exist in any offer besides freelance", async () => {
698+
const offer_params = generateTestOffer({
699+
jobMaxDuration: 8,
700+
jobMinDuration: null,
701+
owner: test_company._id,
702+
});
693703

704+
const res = await request()
705+
.post("/offers/new")
706+
.send(withGodToken(offer_params));
694707
expect(res.status).toBe(HTTPStatus.UNPROCESSABLE_ENTITY);
695-
expect(res.body).toHaveProperty("error_code", ErrorTypes.VALIDATION_ERROR);
696-
expect(res.body).toHaveProperty("errors");
697-
expect(res.body.errors[0]).toHaveProperty("param", "jobMaxDuration");
698-
expect(res.body.errors[0]).toHaveProperty("msg", ValidationReasons.MUST_BE_GREATER_THAN_OR_EQUAL_TO("jobMinDuration"));
699708
});
700709

701710
test("should succeed if jobMaxDuration is greater than jobMinDuration", async () => {

0 commit comments

Comments
 (0)