-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: split labels nationaux and rename autres labels
- Loading branch information
1 parent
fe540b2
commit 9b5ff4d
Showing
28 changed files
with
469 additions
and
184 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/models/dispositif-programme-national/dispositif-programme-national.spec.ts
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,27 @@ | ||
import { DispositifProgrammeNational, DispositifProgrammesNationaux } from './dispositif-programme-national'; | ||
import { DispositifProgrammeNationalError } from './errors'; | ||
|
||
describe('dispositif programme national model', (): void => { | ||
it('should create valid dispositif programmes nationaux', (): void => { | ||
const dispositifProgrammesNationaux: DispositifProgrammesNationaux = DispositifProgrammesNationaux([ | ||
DispositifProgrammeNational.ConseillersNumeriques | ||
]); | ||
|
||
expect(dispositifProgrammesNationaux).toStrictEqual([DispositifProgrammeNational.ConseillersNumeriques]); | ||
}); | ||
|
||
it('should not create invalid dispositif programmes nationaux', (): void => { | ||
expect((): void => { | ||
DispositifProgrammesNationaux(['France Emploi' as DispositifProgrammeNational]); | ||
}).toThrow(new DispositifProgrammeNationalError('France Emploi' as DispositifProgrammeNational)); | ||
}); | ||
|
||
it('should not create invalid dispositif programmes nationaux containing a valid and an invalid value', (): void => { | ||
expect((): void => { | ||
DispositifProgrammesNationaux([ | ||
DispositifProgrammeNational.ConseillersNumeriques, | ||
'France Emploi' as DispositifProgrammeNational | ||
]); | ||
}).toThrow(new DispositifProgrammeNationalError('France Emploi' as DispositifProgrammeNational)); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
src/models/dispositif-programme-national/dispositif-programme-national.ts
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,44 @@ | ||
import { Model } from '../model'; | ||
import { DispositifProgrammeNationalError } from './errors'; | ||
|
||
export enum DispositifProgrammeNational { | ||
AidantsConnect = 'Aidants Connect', | ||
BibliothequesNumeriqueDeReference = 'Bibliothèques numérique de référence', | ||
CertificationPIX = 'Certification PIX', | ||
ConseillersNumeriques = 'Conseillers numériques', | ||
EmmausConnect = 'Emmaüs Connect', | ||
FranceServices = 'France Services', | ||
GrandeEcoleDuNumerique = 'Grande école du numérique', | ||
LaCroixRouge = 'La Croix Rouge', | ||
PointNumeriqueCAF = "Point d'accès numérique CAF", | ||
PromeneursDuNet = 'Promeneurs du net', | ||
RelaisNumeriqueEmmausConnect = 'Relais numérique (Emmaüs Connect)' | ||
} | ||
|
||
export type DispositifProgrammesNationaux = Model<'DispositifProgrammesNationaux', DispositifProgrammeNational[]>; | ||
|
||
export type DispositifProgrammeNationalIndefini = 'dispositif ou programme national indéfini'; | ||
|
||
const firstInvalidDispositifProgrammeNational = (dispositifProgrammeNational: DispositifProgrammeNational): boolean => | ||
!Object.values(DispositifProgrammeNational).includes(dispositifProgrammeNational); | ||
|
||
const throwDispositifProgrammesNationauxError = ( | ||
dispositifProgrammesNationaux: DispositifProgrammeNational[] | ||
): DispositifProgrammesNationaux => { | ||
throw new DispositifProgrammeNationalError( | ||
dispositifProgrammesNationaux.find(firstInvalidDispositifProgrammeNational) ?? 'dispositif ou programme national indéfini' | ||
); | ||
}; | ||
|
||
const isDispositifProgrammesNationaux = ( | ||
dispositifProgrammesNationaux: DispositifProgrammeNational[] | ||
): dispositifProgrammesNationaux is DispositifProgrammesNationaux => | ||
dispositifProgrammesNationaux.find(firstInvalidDispositifProgrammeNational) == null; | ||
|
||
/* eslint-disable-next-line @typescript-eslint/naming-convention */ | ||
export const DispositifProgrammesNationaux = ( | ||
dispositifProgrammesNationaux: DispositifProgrammeNational[] | ||
): DispositifProgrammesNationaux => | ||
isDispositifProgrammesNationaux(dispositifProgrammesNationaux) | ||
? dispositifProgrammesNationaux | ||
: throwDispositifProgrammesNationauxError(dispositifProgrammesNationaux); |
12 changes: 12 additions & 0 deletions
12
src/models/dispositif-programme-national/errors/dispositif-programme-national.error.ts
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,12 @@ | ||
import { ModelError } from '../../../errors'; | ||
import { DispositifProgrammeNational, DispositifProgrammeNationalIndefini } from '../dispositif-programme-national'; | ||
import { LieuMediationNumerique } from '../../lieu-mediation-numerique'; | ||
|
||
export class DispositifProgrammeNationalError extends ModelError<LieuMediationNumerique> { | ||
constructor(dispositifProgrammeNational: DispositifProgrammeNational | DispositifProgrammeNationalIndefini) { | ||
super( | ||
'dispositif_programmes_nationaux', | ||
`Le dispositif programmes national '${dispositifProgrammeNational}' n'est pas une valeur admise` | ||
); | ||
} | ||
} |
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 @@ | ||
export * from './dispositif-programme-national.error'; |
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,2 @@ | ||
export * from './errors'; | ||
export * from './dispositif-programme-national'; |
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,9 @@ | ||
import { ModelError } from '../../../errors'; | ||
import { FormationLabel, FormationLabelIndefini } from '../formation-label'; | ||
import { LieuMediationNumerique } from '../../lieu-mediation-numerique'; | ||
|
||
export class FormationLabelError extends ModelError<LieuMediationNumerique> { | ||
constructor(formationLabel: FormationLabel | FormationLabelIndefini) { | ||
super('formations_labels', `Le label de formation '${formationLabel}' n'est pas une valeur admise`); | ||
} | ||
} |
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 @@ | ||
export * from './formation-label.error'; |
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,22 @@ | ||
import { FormationLabel, FormationsLabels } from './formation-label'; | ||
import { FormationLabelError } from './errors'; | ||
|
||
describe('formations labels model', (): void => { | ||
it('should create valid formations labels', (): void => { | ||
const formationsLabels: FormationsLabels = FormationsLabels([FormationLabel.SudLabs]); | ||
|
||
expect(formationsLabels).toStrictEqual([FormationLabel.SudLabs]); | ||
}); | ||
|
||
it('should not create invalid formation label', (): void => { | ||
expect((): void => { | ||
FormationsLabels(['France Emploi' as FormationLabel]); | ||
}).toThrow(new FormationLabelError('France Emploi' as FormationLabel)); | ||
}); | ||
|
||
it('should not create invalid formation label containing a valid and an invalid value', (): void => { | ||
expect((): void => { | ||
FormationsLabels([FormationLabel.SudLabs, 'Nièvre formation' as FormationLabel]); | ||
}).toThrow(new FormationLabelError('Nièvre formation' as FormationLabel)); | ||
}); | ||
}); |
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,32 @@ | ||
import { Model } from '../model'; | ||
import { FormationLabelError } from './errors'; | ||
|
||
export enum FormationLabel { | ||
FormeAMonEspaceSante = 'Formé à « Mon Espace Santé »', | ||
FormeADuplex = 'Formé à « DUPLEX » (illettrisme)', | ||
ArniaMednum = 'Arnia/MedNum BFC (Bourgogne-Franche-Comté)', | ||
CollectifRessourcesEtActeursReemploi = 'Collectif ressources et acteurs réemploi (Normandie)', | ||
FabriquesDeTerritoire = 'Fabriques de Territoire', | ||
LesEclaireurs = 'Les Éclaireurs du numérique (Drôme)', | ||
MesPapiers = 'Mes Papiers (Métropole de Lyon)', | ||
Ordi3 = 'ORDI 3.0', | ||
SudLabs = 'SUD LABS (PACA)' | ||
} | ||
|
||
export type FormationsLabels = Model<'FormationsLabels', FormationLabel[]>; | ||
|
||
export type FormationLabelIndefini = 'Label de formation indéfini'; | ||
|
||
const firstInvalidFormationLabel = (formationLabel: FormationLabel): boolean => | ||
!Object.values(FormationLabel).includes(formationLabel); | ||
|
||
const throwFormationsLabelsError = (formationsLabels: FormationLabel[]): FormationsLabels => { | ||
throw new FormationLabelError(formationsLabels.find(firstInvalidFormationLabel) ?? 'Label de formation indéfini'); | ||
}; | ||
|
||
const isFormationsLabels = (formationsLabels: FormationLabel[]): formationsLabels is FormationsLabels => | ||
formationsLabels.find(firstInvalidFormationLabel) == null; | ||
|
||
/* eslint-disable-next-line @typescript-eslint/naming-convention */ | ||
export const FormationsLabels = (formationsLabels: FormationLabel[]): FormationsLabels => | ||
isFormationsLabels(formationsLabels) ? formationsLabels : throwFormationsLabelsError(formationsLabels); |
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,2 @@ | ||
export * from './errors'; | ||
export * from './formation-label'; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.