File size: 842 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { createMemoryHistory } from 'history';
import { ApolloProvider } from '@apollo/react-hooks';
import React from 'react';
import { cleanup, render, fireEvent, waitFor } from '@testing-library/react';
import AddChatButton from './AddChatButton';
import { mockApolloClient } from '../../test-helpers';

describe('AddChatButton', () => {
  afterEach(cleanup);

  it('goes back on arrow click', async () => {
    const history = createMemoryHistory();
    const client = mockApolloClient();

    {
      const { container, getByTestId } = render(
        <ApolloProvider client={client}>
          <AddChatButton history={history} />
        </ApolloProvider>
      );

      fireEvent.click(getByTestId('new-chat-button'));

      await waitFor(() =>
        expect(history.location.pathname).toEqual('/new-chat')
      );
    }
  });
});