1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00
metamask-extension/ui/components/institutional/confirm-remove-jwt-modal/confirm-remove-jwt-modal.test.js
Albert Olivé 49f01406c4
[MMI] Added confirm-remove-jwt component (#18186)
* Added confirm-remove-jwt component

* changing folder directory

* Fixed lint issues

* Added story

* Fixed confirm remove jwt imports

* Fixed import

* Finished implementing component

* Fixed capitalize eslint problem

* Fixed PR suggestions

* Changed CustodyAccountList import

* updated snapshot

* Fixed typo

* Moved folder to confirm-remove-jwt-modal

* added index

* Adding filter first
2023-04-28 11:01:40 +02:00

72 lines
1.9 KiB
JavaScript

import React from 'react';
import { fireEvent, waitFor } from '@testing-library/react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import testData from '../../../../.storybook/test-data';
import ConfirmRemoveJwt from '.';
const mockedRemoveAccount = jest.fn();
const mockedHideModal = jest.fn();
jest.mock('../../../store/actions', () => ({
removeAccount: () => mockedRemoveAccount,
hideModal: () => mockedHideModal,
}));
const address = '0xaD6D458402F60fD3Bd25163575031ACDce07538D';
const props = {
hideModal: mockedHideModal,
token: { address },
custodyAccountDetails: [
{
address,
name: 'Test name account',
labels: [],
authDetails: { token: address },
},
],
accounts: [{ address, balance: '0x0' }],
};
const mockStore = {
...testData,
metamask: {},
};
const middleware = [thunk];
const store = configureMockStore(middleware)(mockStore);
const render = () => {
return renderWithProvider(<ConfirmRemoveJwt {...props} />, store);
};
describe('Confirm Remove JWT', function () {
it('should render correctly', () => {
const { container } = render();
expect(container).toMatchSnapshot();
});
it('should show full token address when "show more" is clicked', () => {
const { getByText } = render();
const showMoreLink = getByText('Show more');
fireEvent.click(showMoreLink);
const fullTokenAddress = getByText(address);
expect(fullTokenAddress).toBeInTheDocument();
});
it('dispatches removeAccount action when user clicks remove button', async () => {
const { getByText } = render();
const removeButton = getByText('Remove');
fireEvent.click(removeButton);
await waitFor(() => expect(mockedRemoveAccount).toHaveBeenCalled());
expect(mockedHideModal).toHaveBeenCalled();
});
});