-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add test for offer and employer model
- Loading branch information
Showing
4 changed files
with
65 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { connectDB, disconnectDB } from './dbTestConnection'; | ||
import EmployerModel from '../models/employerModel'; | ||
import { Employer } from '../interfaces/employerInterface'; | ||
|
||
describe('test Employer Model', () => { | ||
beforeAll(async () => { | ||
await connectDB(); | ||
}); | ||
afterAll(async () => { | ||
await disconnectDB(); | ||
}); | ||
it('create new talent', async () => { | ||
const mockData: Employer = { | ||
name: 'Test', | ||
email: '[email protected]', | ||
password: 'secret', | ||
createdAt: new Date(), | ||
}; | ||
const newEmployer = await EmployerModel.create({ ...mockData }); | ||
expect(newEmployer._id).toBeDefined(); | ||
expect(newEmployer.name).toBe(mockData.name); | ||
expect(newEmployer.email).toBe(mockData.email); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { connectDB, disconnectDB } from './dbTestConnection'; | ||
import OfferModel from '../models/offerModel'; | ||
import { Offer } from '../interfaces/offerInterface'; | ||
|
||
describe('test offer Model', () => { | ||
beforeAll(async () => { | ||
await connectDB(); | ||
}); | ||
afterAll(async () => { | ||
await disconnectDB(); | ||
}); | ||
it('create new talent', async () => { | ||
const mockData: Offer = { | ||
talentId: 'Test-id', | ||
employerId: 'test-id2', | ||
title: 'full-stack dev', | ||
createdAt: new Date(), | ||
}; | ||
const newOffer = await OfferModel.create({ ...mockData }); | ||
expect(newOffer._id).toBeDefined(); | ||
expect(newOffer.talentId).toBe(mockData.talentId); | ||
expect(newOffer.employerId).toBe(mockData.employerId); | ||
expect(newOffer.accepted).toBe(false); | ||
}); | ||
}); |