1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/ui/components/multichain/menu-items/account-details-menu-item.test.js
David Walsh 46b2290822
Fix #20006 - Add Address Details and View on Explorer to Global Menu (#20013)
* Fix #20006 - Add Address Details and View on Explorer to Global Menu

* Fix tests
2023-07-18 17:01:07 -05:00

39 lines
1.2 KiB
JavaScript

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,
);
});
});