targo-backend/test/factories/bank-code.factory.ts

27 lines
814 B
TypeScript

export type BankCodePayload = {
type: string;
categorie: string;
modifier: number;
bank_code: string;
};
const randNum = (min = 1, max = 999) =>
Math.floor(Math.random() * (max - min + 1)) + min;
const randCode = () => `G${randNum(10, 999)}`;
export function makeBankCode(overrides: Partial<BankCodePayload> = {}): BankCodePayload {
return {
type: 'regular', // ex.: regular, vacation, sick...
categorie: 'shift', // ex.: shift, expense, leave
modifier: 1.5, // ex.: 0, 0.72, 1, 1.5, 2
bank_code: randCode(), // ex.: G1, G345, G501...
...overrides,
};
}
// Délibérément invalide pour déclencher 400 via ValidationPipe
export function makeInvalidBankCode(): Record<string, unknown> {
return {}; // manque tous les champs requis
}