-
Notifications
You must be signed in to change notification settings - Fork 2
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
34b40e3
commit 974ec68
Showing
7 changed files
with
220 additions
and
58 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
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { ActionsRepositoryMock } from './adapters/actions.repository.mock'; | ||
import { CatalogueActionsPresenterImpl } from '@/domaines/actions/adapters/catalogueActions.presenter.impl'; | ||
import { CatalogueActionsViewModel } from '@/domaines/actions/ports/catalogueActions.presenter'; | ||
import { Action, CatalogueActions, TypeAction } from '@/domaines/actions/ports/actions.repository'; | ||
import { ActionViewModel } from '@/domaines/actions/ports/actions.presenter'; | ||
import { ActionsPresenterImpl } from '@/domaines/actions/adapters/actions.presenter.impl'; | ||
import { ClefThematiqueAPI } from '@/domaines/thematiques/MenuThematiques'; | ||
import { FiltrerCatalogueActionsUsecase } from '@/domaines/actions/filtrerCatalogueActions.usecase'; | ||
|
||
describe("Fichier de tests concernant la récupération du catalogue d'actions", () => { | ||
it('Doit filtrer correctement le catalogue actions et les actions', async () => { | ||
// GIVEN | ||
const actions: Action[] = [ | ||
{ | ||
code: 'code-action-test2', | ||
titre: 'Tester une nouvelle **recette végétarienne** 2', | ||
sousTitre: | ||
'Faites des économies et le plein de vitamines ! Cette semaine, on cuisine une recette saine et délicieuse !', | ||
nombreDePersonnes: 4, | ||
nombreAidesDisponibles: 5, | ||
type: TypeAction.BILAN, | ||
dejaVue: true, | ||
}, | ||
]; | ||
|
||
const catalogue: CatalogueActions = { | ||
actions, | ||
filtres: [ | ||
{ | ||
code: ClefThematiqueAPI.transports, | ||
label: 'Transport !', | ||
selected: false, | ||
}, | ||
{ | ||
code: ClefThematiqueAPI.alimentation, | ||
label: 'Alimentation !', | ||
selected: true, | ||
}, | ||
], | ||
consultation: 'tout', | ||
}; | ||
|
||
// WHEN | ||
const usecase = new FiltrerCatalogueActionsUsecase(ActionsRepositoryMock.avecCatalogue(catalogue)); | ||
await usecase.execute( | ||
'id-utilisateur', | ||
[ClefThematiqueAPI.alimentation], | ||
'2', | ||
true, | ||
new CatalogueActionsPresenterImpl(expectedCatalogue), | ||
new ActionsPresenterImpl(expectedActions), | ||
); | ||
|
||
// THEN | ||
function expectedActions(viewModel: ActionViewModel[]): void { | ||
expect(viewModel).toStrictEqual<ActionViewModel[]>([ | ||
{ | ||
code: 'code-action-test2', | ||
titre: 'Tester une nouvelle <span class="text--bold">recette végétarienne</span> 2', | ||
nombreDePersonnes: '<span class="text--bold">4</span> défis réalisés', | ||
aidesDisponibles: '<span class="text--bold">5</span> aides disponibles', | ||
dejaVue: true, | ||
url: { | ||
name: 'action-individuelle', | ||
params: { | ||
id: 'code-action-test2', | ||
titre: 'tester-une-nouvelle-recette-vegetarienne-2', | ||
type: 'bilan', | ||
}, | ||
}, | ||
}, | ||
]); | ||
} | ||
function expectedCatalogue(viewModel: CatalogueActionsViewModel): void { | ||
expect(viewModel).toStrictEqual<CatalogueActionsViewModel>({ | ||
filtres: [ | ||
{ | ||
id: ClefThematiqueAPI.transports, | ||
label: 'Transport !', | ||
checked: false, | ||
}, | ||
{ | ||
id: ClefThematiqueAPI.alimentation, | ||
label: 'Alimentation !', | ||
checked: true, | ||
}, | ||
], | ||
phraseNombreActions: '1 action', | ||
}); | ||
} | ||
}); | ||
}); |
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