File size: 1,210 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { act, render, waitFor } from '@testing-library/react';
import React from 'react';

import { createSearchClient } from '../../../../../test/mock';
import { Configure } from '../Configure';
import { InstantSearch } from '../InstantSearch';

describe('Configure', () => {
  test('does not render anything', () => {
    const searchClient = createSearchClient({});

    const { container } = render(
      <InstantSearch indexName="indexName" searchClient={searchClient}>
        <Configure hitsPerPage={666} />
      </InstantSearch>
    );

    expect(container).toMatchInlineSnapshot(`<div />`);
  });

  test('sets search parameters', async () => {
    const searchClient = createSearchClient({});

    act(() => {
      render(
        <InstantSearch indexName="indexName" searchClient={searchClient}>
          <Configure hitsPerPage={666} />
        </InstantSearch>
      );
    });

    await waitFor(() => {
      expect(searchClient.search).toHaveBeenCalledTimes(1);
      expect(searchClient.search).toHaveBeenCalledWith([
        {
          indexName: 'indexName',
          params: expect.objectContaining({
            hitsPerPage: 666,
          }),
        },
      ]);
    });
  });
});