I have a problem can't write a correct test for one of my reducers.
My reducer look:
case "FILTER_BY_VALUE": {
return {
...state,
search: payload,
filteredProducts: [
...state.products.filter(product =>
product.name.toLowerCase().startsWith(payload.toLowerCase())
)
]
};
}
My reducer filter an array of objects by value (in my expamle it is payload)
My test look :
it("FILTER_BY_VALUE", () => {
const action = {
type: "FILTER_BY_VALUE",
payload: "dsf"
};
expect(data(initialState, action)).toEqual({
...initialState,
search: action.payload
// filteredProducts: Object
});
});

Aucun commentaire:
Enregistrer un commentaire