-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d37e91
commit fab34cd
Showing
1 changed file
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const { isDeclarationligibleToEig } = require("../eig"); | ||
const { statuts: dsStatuts } = require("../ds-statuts"); | ||
const { expect } = require("@playwright/test"); | ||
|
||
describe("isDeclarationligibleToEig", () => { | ||
const declaration = { | ||
id: 26, | ||
libelle: "declaration1", | ||
dateDebut: "2024-09-01", | ||
dateFin: "2024-09-07", | ||
}; | ||
|
||
const allStatuts = Object.values(dsStatuts); | ||
|
||
const okStatuts = [ | ||
dsStatuts.SEJOUR_EN_COURS, | ||
dsStatuts.VALIDEE_8J, | ||
dsStatuts.TERMINEE, | ||
]; | ||
|
||
const badStatus = allStatuts.filter((s) => !okStatuts.includes(s)); | ||
|
||
it.each(okStatuts)( | ||
"should return true for statut %p and good date range", | ||
(statut) => { | ||
declaration.statut = statut; | ||
jest.useFakeTimers().setSystemTime(new Date("2024-09-01")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(true); | ||
|
||
jest.useFakeTimers().setSystemTime(new Date("2024-09-06")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(true); | ||
|
||
jest.useFakeTimers().setSystemTime(new Date("2024-09-07")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(true); | ||
|
||
jest.useFakeTimers().setSystemTime(new Date("2024-09-14")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(true); | ||
}, | ||
); | ||
|
||
it.each(badStatus)( | ||
"should return false for statut %p and good date range", | ||
(statut) => { | ||
declaration.statut = statut; | ||
jest.useFakeTimers().setSystemTime(new Date("2024-09-01")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(false); | ||
|
||
jest.useFakeTimers().setSystemTime(new Date("2024-09-06")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(false); | ||
|
||
jest.useFakeTimers().setSystemTime(new Date("2024-09-07")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(false); | ||
|
||
jest.useFakeTimers().setSystemTime(new Date("2024-09-14")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(false); | ||
}, | ||
); | ||
|
||
it.each(allStatuts)( | ||
"should return false for statut %p and bad date range", | ||
(statut) => { | ||
declaration.statut = statut; | ||
jest.useFakeTimers().setSystemTime(new Date("2024-08-31")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(false); | ||
|
||
jest.useFakeTimers().setSystemTime(new Date("2024-09-15")); | ||
expect(isDeclarationligibleToEig(declaration)).toBe(false); | ||
}, | ||
); | ||
}); |