Skip to content

chore: add unit tests to filterSelectionState (plugin-hrm-form/src/states/resources/filterSelectionState/) #4058

@gpaoloni

Description

@gpaoloni

Context

plugin-hrm-form/src/states/resources/index.ts contains the Redux reducer for state management of "resources".

One of the actions handled by this reducer is loadReferenceLocationsAsyncAction.fulfilled. How this action is handled, is a parameterized function, handleLoadReferenceLocationsAsyncActionFulfilled, that depends on the implementation of the resources (different use cases have different resource shapes).
Each of this implementations expose a FilterSelectionState, as described in plugin-hrm-form/src/components/resources/mappingComponents/index.tsx
At the moment there are two of this implementations:

  • plugin-hrm-form/src/states/resources/filterSelectionState/khp/index.ts
  • plugin-hrm-form/src/states/resources/filterSelectionState/usch/index.ts

Each of this integrations expose three functions:

  • loadReferenceActionFunction: specifies "how to retrieve the references, which are lists of options used as search filters".
  • handleLoadReferenceLocationsAsyncActionFulfilled: specifies "how to update the state once the load reference action fulfills".
  • handlerUpdateSearchFormAction: specifies "how a state update is handled when interacting with the search forms".

Assignment

Write unit tests for both of this custom filterSelectionState implementations, taking into consideration it's differences. The tests must assert

  • Initial state is properly loaded onto resources reducer.
  • Mocking the API calls used for the actual implementation (returning mocked references), assert that loadReferenceActionFunction if fulfills, then the handleLoadReferenceLocationsAsyncActionFulfilled is called.
    • Assert that the state is properly handled, considering edge cases (e.g. usch implementation have two operating modes, one if the defaultCountryTarget is part of the references list and one if it's not).
  • Assert that handlerUpdateSearchFormAction performs the state updates accordingly.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions