mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 06:07:06 +01:00
fcfb8a8938
* added redesign storybook * updated token list * updated css * fixed lint error * updated the new token list component * fixed redesign folder error * reverted changes in settings.json * updated redesign to multichain * added feature flag * reverted settings.json * added detect token banner * added button componeny * fixed lint errors * removed settings * fixed lint errors * added stories for multichain * updated no token found string * updated lint error * updated padding values * updated padding values * updated tabs with role button * updated hover state * updated components with multichain * fixed lint errors * updated multichain import token link * updated a tag * updated fixes * updated onClick to handleClick * updated setShowDetectedTokens proptype * updated multichain tokenlist with item suffix * updated tests * updated tests * updated token list css * updated snapshot * updated text * reverted story * added story for multichain token list * updated story * updated tooltip * updated the new token list component * fixed redesign folder error * added feature flag * reverted unused setting change * removed token list * fixed lint error * updated status * updated tooltip * updated token-list-item changes * updated actionbutton click for detect token banner * updated snapshot * updated symbol * updated styles * updated eth decimal and token url * updated snapshot * updated scripts * updated snapshots
102 lines
2.4 KiB
JavaScript
102 lines
2.4 KiB
JavaScript
import React from 'react';
|
|
import configureMockStore from 'redux-mock-store';
|
|
import { fireEvent, screen } from '@testing-library/react';
|
|
import { detectNewTokens } from '../../../store/actions';
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
import { MultichainImportTokenLink } from './multichain-import-token-link';
|
|
|
|
const mockPushHistory = jest.fn();
|
|
|
|
jest.mock('react-router-dom', () => {
|
|
const original = jest.requireActual('react-router-dom');
|
|
return {
|
|
...original,
|
|
useLocation: jest.fn(() => ({ search: '' })),
|
|
useHistory: () => ({
|
|
push: mockPushHistory,
|
|
}),
|
|
};
|
|
});
|
|
|
|
jest.mock('../../../store/actions.ts', () => ({
|
|
detectNewTokens: jest.fn(),
|
|
}));
|
|
|
|
describe('Import Token Link', () => {
|
|
it('should match snapshot for goerli chainId', () => {
|
|
const mockState = {
|
|
metamask: {
|
|
provider: {
|
|
chainId: '0x5',
|
|
},
|
|
},
|
|
};
|
|
|
|
const store = configureMockStore()(mockState);
|
|
|
|
const { container } = renderWithProvider(
|
|
<MultichainImportTokenLink />,
|
|
store,
|
|
);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it('should match snapshot for mainnet chainId', () => {
|
|
const mockState = {
|
|
metamask: {
|
|
provider: {
|
|
chainId: '0x1',
|
|
},
|
|
},
|
|
};
|
|
|
|
const store = configureMockStore()(mockState);
|
|
|
|
const { container } = renderWithProvider(
|
|
<MultichainImportTokenLink />,
|
|
store,
|
|
);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it('should detectNewTokens when clicking refresh', () => {
|
|
const mockState = {
|
|
metamask: {
|
|
provider: {
|
|
chainId: '0x5',
|
|
},
|
|
},
|
|
};
|
|
|
|
const store = configureMockStore()(mockState);
|
|
|
|
renderWithProvider(<MultichainImportTokenLink />, store);
|
|
|
|
const refreshList = screen.getByTestId('refresh-list-button');
|
|
fireEvent.click(refreshList);
|
|
|
|
expect(detectNewTokens).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should push import token route', () => {
|
|
const mockState = {
|
|
metamask: {
|
|
provider: {
|
|
chainId: '0x5',
|
|
},
|
|
},
|
|
};
|
|
|
|
const store = configureMockStore()(mockState);
|
|
|
|
renderWithProvider(<MultichainImportTokenLink />, store);
|
|
|
|
const importToken = screen.getByTestId('import-token-button');
|
|
fireEvent.click(importToken);
|
|
|
|
expect(mockPushHistory).toHaveBeenCalledWith('/import-token');
|
|
});
|
|
});
|