front: add useSimulationResults hook tests#16004
Conversation
ee8ede1 to
6b73724
Compare
6b73724 to
5c62125
Compare
5c62125 to
c940591
Compare
There was a problem hiding this comment.
Nice work on the test coverage! I had a thought about the mock setup.
I think we should only mock the 5 actual I/O dependencies (React, Redux, RTK endpoints). The other 9 are pure functions, so mocking them adds a lot of setup without giving us much assertions end up checking that mocks were called rather than what the hook actually produces.
Also, the useMemo that builds the effective train (useSimulationResults.ts:42-72) is pure domain logic. We could extract it as a buildEffectiveTrain(selectedTrainId, timetableItem) function. Tthat way we can unit-test the occurrence/exception resolution with zero mocks.
Together with the mock cleanup above, this would simplify the hook tests a lot. Happy to handle it in a follow-up PR.
c940591 to
008ad99
Compare
Yohh
left a comment
There was a problem hiding this comment.
thanks!
this test is set in front/src/applications/operationalStudies/__tests__/, could you set it closer in front/src/applications/operationalStudies/hooks/__tests__/?
need more time to review deeper
008ad99 to
4c59910
Compare
53a3404 to
5e3a9ab
Compare
5e3a9ab to
9c84bc4
Compare
Signed-off-by: Maymanaf <med.aymen.naf@gmail.com>
9c84bc4 to
8c3a39c
Compare
closes #16668
Critical behaviors covered: