import reducerConfig, { selectFilterFn, selectFilterMode } from './filter' const { reducer: filterReducer } = reducerConfig const getStateMock = () => reducerConfig.initialState describe('filterReducer', () => { describe('unknown action', () => { it('should not modify the state', () => { const state = getStateMock() const newState = filterReducer(state, { type: 'nope' } as any) expect(state).toBe(newState) }) }) describe('applyProps', () => { it('should replace the filter fn', () => { const state = filterReducer(getStateMock(), { type: 'applyProps', payload: { filter: () => true, }, }) const fakeRow = {} expect(selectFilterFn(state)?.(fakeRow)).toBe(true) }) it('should set the filterMode', () => { const state = filterReducer(getStateMock(), { type: 'applyProps', payload: { filterMode: 'highlight', }, }) expect(selectFilterMode(state)).toBe('highlight') }) }) })