-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from NIAEFEUP/feature/offers-search
Added Search funcionality to GET /offers
- Loading branch information
Showing
13 changed files
with
514 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
const Company = require("../src/models/Company"); | ||
const SchemaTester = require("./utils/SchemaTester"); | ||
const CompanyConstants = require("../src/models/constants/Company"); | ||
const { DAY_TO_MS } = require("./utils/TimeConstants"); | ||
const Offer = require("../src/models/Offer"); | ||
|
||
const CompanySchemaTester = SchemaTester(Company); | ||
|
||
|
@@ -16,4 +18,50 @@ describe("# Company Schema tests", () => { | |
CompanySchemaTester.maxLength("name", CompanyConstants.companyName.max_length); | ||
}); | ||
}); | ||
|
||
describe("Hook tests", () => { | ||
|
||
describe("Company name update", () => { | ||
|
||
let company; | ||
|
||
beforeAll(async () => { | ||
company = await Company.create({ | ||
name: "first name" | ||
}); | ||
const offer = { | ||
title: "Test Offer", | ||
publishDate: new Date(Date.now() - (DAY_TO_MS)), | ||
publishEndDate: new Date(Date.now() + (DAY_TO_MS)), | ||
description: "For Testing Purposes", | ||
contacts: ["[email protected]", "229417766"], | ||
jobType: "SUMMER INTERNSHIP", | ||
fields: ["DEVOPS", "MACHINE LEARNING", "OTHER"], | ||
technologies: ["React", "CSS"], | ||
location: "Testing Street, Test City, 123", | ||
owner: company._id, | ||
ownerName: company.name | ||
}; | ||
|
||
await Offer.create([offer, offer]); | ||
}); | ||
|
||
afterAll(async () => { | ||
await Offer.deleteMany({}); | ||
await Company.deleteMany({}); | ||
}); | ||
|
||
test("Should update offers ownerName on company name update", async () => { | ||
const offersBefore = await Offer.find({ owner: company._id }); | ||
|
||
expect(offersBefore.every(({ ownerName }) => ownerName === "first name")).toBe(true); | ||
|
||
await Company.findByIdAndUpdate(company._id, { name: "new name" }, { new: true }); | ||
|
||
const offersAfter = await Offer.find({ owner: company._id }); | ||
|
||
expect(offersAfter.every(({ ownerName }) => ownerName === "new name")).toBe(true); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.