I try to test my reducer with react testing library and I don't understand why I get results that are not equal to the expected. Please could you explain to me?
my reducer
export const myReducer = (state = initialState, { type, payload }) => {
switch (type) {
case 'GET_DATA':
return [...payload];
default:
return state;
}
};
my test
import { mockedState } from 'mocks';
import {
myReducer,
GET_DATA,
} from 'store';
const initialState = []
describe('reducer', () => {
it('should get data', () => {
const getAction = {
type: GET_DATA,
payload: mockedState.data,
};
expect(myReducer(initialState, getAction )).toEqual([...mockedState.data]);
});
})