-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
… qui n'est plus une dépendance du projet.
- Loading branch information
Showing
2 changed files
with
24 additions
and
57 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 |
---|---|---|
@@ -1,23 +1,20 @@ | ||
import { describe, expect } from "vitest"; | ||
import { fc, it } from "@fast-check/vitest"; | ||
import { UnionPetitMoyenGrand } from "../../src/Domain/Simulateur/ChampsSimulateur.definitions"; | ||
import { ValeursPetitMoyenGrand } from "../../src/Domain/Simulateur/ChampsSimulateur.valeurs"; | ||
import { describe, expect, it } from "vitest"; | ||
import { estPetiteEntreprise } from "../../src/Domain/Simulateur/services/TailleEntreprise/TailleEntite.predicats"; | ||
|
||
describe("Tailles entreprises", () => { | ||
describe(estPetiteEntreprise, () => { | ||
it("Est petite lorsque les 2 paramètres sont petits", () => { | ||
expect(estPetiteEntreprise(["petit"], ["petit"])).toBeTruthy(); | ||
}); | ||
it.prop([ | ||
fc.constantFrom<UnionPetitMoyenGrand>(...ValeursPetitMoyenGrand), | ||
fc.constantFrom<UnionPetitMoyenGrand>("moyen", "grand"), | ||
])( | ||
"N'est pas petite lorsque l'un des 2 n'est pas 'petit'", | ||
(param1, param2) => { | ||
expect(estPetiteEntreprise([param1], [param2])).toBeFalsy(); | ||
expect(estPetiteEntreprise([param2], [param1])).toBeFalsy(); | ||
}, | ||
); | ||
|
||
it("n'est pas petite lorsque le nombre d'employés n'est pas petit", () => { | ||
expect(estPetiteEntreprise(["moyen"], ["petit"])).toBeFalsy(); | ||
expect(estPetiteEntreprise(["grand"], ["petit"])).toBeFalsy(); | ||
}); | ||
|
||
it("n'est pas petite lorsque le chiffre d'affaires n'est pas petit", () => { | ||
expect(estPetiteEntreprise(["petit"], ["moyen"])).toBeFalsy(); | ||
expect(estPetiteEntreprise(["petit"], ["grand"])).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
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,55 +1,25 @@ | ||
import { fc } from "@fast-check/vitest"; | ||
import { describe, expect, it } from "vitest"; | ||
import { certains, tous } from "../../../utils/services/arrays.predicats"; | ||
|
||
describe(tous, () => { | ||
const estPositif = (n: number) => n >= 0; | ||
const tousPositifs = tous<number>(estPositif); | ||
it("vérifie tousPositifs quand tous les éléments sont positif", () => | ||
fc.assert( | ||
fc.property<[Array<number>]>( | ||
fc.uniqueArray(fc.integer({ min: 0 }), { minLength: 1 }), | ||
(ensemble) => { | ||
expect(tousPositifs(ensemble)).toBeTruthy(); | ||
}, | ||
), | ||
)); | ||
it("ne vérifie pas tousPositifs quand tous les éléments sont négatifs", () => | ||
fc.assert( | ||
fc.property<[Array<number>]>( | ||
fc.uniqueArray(fc.integer({ max: -1 })), | ||
(ensemble) => { | ||
expect(tousPositifs(ensemble)).toBeFalsy(); | ||
}, | ||
), | ||
)); | ||
it("vérifie tousPositifs quand tous les éléments sont positif", () => { | ||
expect(tousPositifs([1, 2, 3])).toBeTruthy(); | ||
}); | ||
|
||
it("ne vérifie pas tousPositifs quand tous les éléments sont négatifs", () => { | ||
expect(tousPositifs([-1, 1])).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe(certains, () => { | ||
const estPositif = (n: number) => n >= 0; | ||
const certainsPositifs = certains<number>(estPositif); | ||
it("vérifie certainsPositifs quand tous les éléments sont négatifs sauf un", () => | ||
fc.assert( | ||
fc.property<[Array<number>]>( | ||
fc | ||
.tuple(fc.uniqueArray(fc.integer({ max: 0 })), fc.integer({ min: 0 })) | ||
.chain(([tableauNegatif, entierPositif]) => | ||
fc.shuffledSubarray([...tableauNegatif, entierPositif], { | ||
minLength: tableauNegatif.length + 1, | ||
}), | ||
), | ||
(ensemble) => { | ||
expect(certainsPositifs(ensemble)).toBeTruthy(); | ||
}, | ||
), | ||
)); | ||
it("ne vérifie pas tousPositifs quand tous les éléments sont négatifs", () => | ||
fc.assert( | ||
fc.property<[Array<number>]>( | ||
fc.uniqueArray(fc.integer({ max: -1 })), | ||
(ensemble) => { | ||
expect(certainsPositifs(ensemble)).toBeFalsy(); | ||
}, | ||
), | ||
)); | ||
it("vérifie certainsPositifs quand tous les éléments sont négatifs sauf un", () => { | ||
expect(certainsPositifs([1, 2, -1])).toBeTruthy(); | ||
}); | ||
it("ne vérifie pas tousPositifs quand tous les éléments sont négatifs", () => { | ||
expect(certainsPositifs([-1, -2])).toBeFalsy(); | ||
}); | ||
}); |