1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/components/multichain/menu-items/account-details-menu-item.test.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { renderWithProvider, fireEvent } from '../../../../test/jest';
import configureStore from '../../../store/store';
import mockState from '../../../../test/data/mock-state.json';
import * as actions from '../../../store/actions';
import { AccountDetailsMenuItem } from '.';
const render = () => {
const store = configureStore(mockState);
return renderWithProvider(
<AccountDetailsMenuItem
metricsLocation="Global Menu"
address={mockState.metamask.selectedAddress}
closeMenu={jest.fn()}
/>,
store,
);
};
jest.mock('../../../store/actions', () => ({
...jest.requireActual('../../../store/actions.ts'),
setAccountDetailsAddress: jest.fn().mockReturnValue({ type: 'TYPE' }),
}));
describe('AccountDetailsMenuItem', () => {
it('opens the Account Details modal with the correct address', () => {
global.platform = { openTab: jest.fn() };
const { getByText, getByTestId } = render();
expect(getByText('Account details')).toBeInTheDocument();
fireEvent.click(getByTestId('account-list-menu-details'));
expect(actions.setAccountDetailsAddress).toHaveBeenCalledWith(
mockState.metamask.selectedAddress,
);
});
});