-
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.
[REMANIEMENT][AIDANT] Prends en compte l'ajout de la colonne type dan…
…s utilisateur_mac au niveau de l'entrepôt Aidant
- Loading branch information
Showing
3 changed files
with
93 additions
and
9 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 |
---|---|---|
|
@@ -64,6 +64,9 @@ import { EntrepotAidantPostgres as EntrepotAidantPostgresExtraction } from '../. | |
import { Aidant as AidantExtraction } from '../../../../src/administration/aidants/aidants-selon-nombre-diagnostics/Types'; | ||
import { ProfilAidant } from '../../../../src/espace-aidant/profil/profilAidant'; | ||
import { EntrepotProfilAidantPostgres } from '../../../../src/infrastructure/entrepots/postgres/EntrepotProfilAidantPostgres'; | ||
import knexfile from './../../../../src/infrastructure/entrepots/postgres/knexfile'; | ||
import knex from 'knex'; | ||
import { AggregatNonTrouve } from '../../../../src/domaine/Aggregat'; | ||
|
||
describe('Entrepots Postgres', () => { | ||
describe('Entrepot Statistiques Postgres', () => { | ||
|
@@ -677,8 +680,8 @@ describe('Entrepot Aidant', () => { | |
}); | ||
}); | ||
|
||
describe('Recherche par identifiant', () => { | ||
it("l'aidant est trouvé", async () => { | ||
describe('Recherche par email', () => { | ||
it("L'aidant est trouvé", async () => { | ||
const aidant = unAidant().construis(); | ||
const serviceDeChiffrement = new FauxServiceDeChiffrement( | ||
new Map([ | ||
|
@@ -695,14 +698,72 @@ describe('Entrepot Aidant', () => { | |
expect(aidantTrouve).toStrictEqual<Aidant>(aidant); | ||
}); | ||
|
||
it("l'aidant n'est pas trouvé", () => { | ||
it("Retourne un erreur s'il ne s'agit pas d'un Aidant", async () => { | ||
await knex(knexfile) | ||
.insert({ | ||
id: crypto.randomUUID(), | ||
type: 'UTILISATEUR_INSCRIT', | ||
donnees: { email: '[email protected]' }, | ||
}) | ||
.into('utilisateurs_mac'); | ||
|
||
const aidantTrouve = new EntrepotAidantPostgres( | ||
new ServiceDeChiffrementClair() | ||
).rechercheParEmail('[email protected]'); | ||
|
||
expect(aidantTrouve).rejects.toStrictEqual( | ||
new AggregatNonTrouve('aidant') | ||
); | ||
}); | ||
|
||
it("L'aidant n'est pas trouvé", () => { | ||
expect( | ||
new EntrepotAidantPostgres( | ||
new FauxServiceDeChiffrement(new Map()) | ||
).rechercheParEmail('identifiant-inconnu') | ||
).rejects.toThrow(new Error("Le aidant demandé n'existe pas.")); | ||
}); | ||
}); | ||
|
||
describe('Pour le type Aidant', () => { | ||
it('Retourne une erreur s’il ne s’agit pas d’un Aidant', async () => { | ||
const id = crypto.randomUUID(); | ||
await knex(knexfile) | ||
.insert({ | ||
id, | ||
type: 'UTILISATEUR_INSCRIT', | ||
donnees: { email: '[email protected]' }, | ||
}) | ||
.into('utilisateurs_mac'); | ||
|
||
const aidantTrouve = new EntrepotAidantPostgres( | ||
new ServiceDeChiffrementClair() | ||
).lis(id); | ||
|
||
expect(aidantTrouve).rejects.toStrictEqual( | ||
new AggregatNonTrouve('aidant') | ||
); | ||
}); | ||
|
||
it('Retourne uniquement les Aidants', async () => { | ||
const aidant = unAidant().construis(); | ||
const serviceDeChiffrement = new ServiceDeChiffrementClair(); | ||
await new EntrepotAidantPostgres(serviceDeChiffrement).persiste(aidant); | ||
await knex(knexfile) | ||
.insert({ | ||
id: crypto.randomUUID(), | ||
type: 'UTILISATEUR_INSCRIT', | ||
donnees: { email: '[email protected]' }, | ||
}) | ||
.into('utilisateurs_mac'); | ||
|
||
const aidants = await new EntrepotAidantPostgres( | ||
serviceDeChiffrement | ||
).tous(); | ||
|
||
expect(aidants).toStrictEqual<Aidant[]>([aidant]); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('EntrepotAidantExtraction', () => { | ||
|