2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2022-10-11 19:54:50 +02:00
|
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import copyToClipboard from 'copy-to-clipboard';
|
|
|
|
import { fireEvent } from '@testing-library/react';
|
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
|
|
import mockState from '../../../../test/data/mock-state.json';
|
|
|
|
import SelectedAccount from '.';
|
|
|
|
|
|
|
|
jest.mock('copy-to-clipboard');
|
2018-09-15 22:31:21 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('SelectedAccount Component', () => {
|
2022-10-11 19:54:50 +02:00
|
|
|
const mockStore = configureMockStore()(mockState);
|
|
|
|
|
|
|
|
it('should match snapshot', () => {
|
|
|
|
const { container } = renderWithProvider(<SelectedAccount />, mockStore);
|
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should copy checksum address to clipboard when button is clicked', () => {
|
|
|
|
const { queryByTestId } = renderWithProvider(
|
|
|
|
<SelectedAccount />,
|
|
|
|
mockStore,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2022-10-11 19:54:50 +02:00
|
|
|
|
|
|
|
fireEvent.click(queryByTestId('selected-account-click'));
|
|
|
|
|
|
|
|
expect(copyToClipboard).toHaveBeenCalledWith(
|
|
|
|
'0x0DCD5D886577d5081B0c52e242Ef29E70Be3E7bc',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|