function _searchStart(params) {
   sagaTester.dispatch(
     searchStart({
       errorHandlerId: 'create-stub-error-handler-id',
       ...params,
     }),
   );
 }
Example #2
0
 it('sets the filters and loading', () => {
   const state = search(
     initialState,
     searchStart({
       errorHandlerId: 'foo',
       filters: { query: 'foo' },
     }),
   );
   expect(state.filters).toEqual({ query: 'foo' });
   expect(state.loading).toBe(true);
   expect(state.results).toEqual([]);
   expect(state.count).toEqual(0);
 });
Example #3
0
    it('resets the state to its initial state', () => {
      const state = search(
        initialState,
        searchStart({
          errorHandlerId: 'foo',
          filters: { query: 'foo' },
        }),
      );
      expect(state).not.toEqual(initialState);

      const newState = search(state, resetSearch());
      expect(newState).toEqual(initialState);
    });
Example #4
0
    it('resets the results and loading flag', () => {
      const state = search(
        initialState,
        searchStart({
          errorHandlerId: 'foo',
          filters: { query: 'foo' },
        }),
      );
      expect(state.filters).toEqual({ query: 'foo' });
      expect(state.loading).toBe(true);
      expect(state.results).toEqual([]);

      const newState = search(state, abortSearch());
      expect(newState.filters).toEqual({ query: 'foo' });
      expect(newState.loading).toBe(false);
      expect(newState.results).toEqual([]);
      expect(newState.count).toEqual(0);
    });
  function render({ filters = {}, pathname = '/search/', ...props } = {}) {
    const errorHandler = createStubErrorHandler();
    const { store } = dispatchClientMetadata();

    store.dispatch(searchStart({ errorHandlerId: errorHandler.id, filters }));

    return shallowUntilTarget(
      <SearchFilters
        i18n={fakeI18n()}
        pathname={pathname}
        store={store}
        {...props}
      />,
      SearchFiltersBase,
      {
        shallowOptions: createContextWithFakeRouter({
          history: fakeHistory,
          location: createFakeLocation({ pathname }),
        }),
      },
    );
  }