mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
c3b79bb358
* Show custom tokens in Swaps * Add messages for adding a custom token in Swaps * Add the first version of importing custom tokens in swaps * Fix lint rules * Create a new component: ImportToken * Remove a pointer cursor from regular heading * Fix a CSS issue for tokens with long names * Update a comment * Don’t return a custom token if it doesn’t have symbol or decimals * Only search by contract address if nothing was found * Track “Token Imported” event * Fix unit tests * Import tracking for “Token Imported”, increase token icon font size * Disable token import for Source Token * Update logic and content for notifications, update tests * Do not hide a dropdown placeholder on click, so a user can click on a link * Update a key name * Update styling for the “danger” type notification in Swaps * Show either a warning or danger notification based on token verification occurences * Remove testnets from SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP * Use the “shouldSearchForImports” prop * Create a new function for handling token import: “onOpenImportTokenModalClick” * Filter token duplicities before iterating over tokens * Use “address” instead of “symbol” for checking uniqueness * Trigger Build * Use a new API (/token) to get token data for importing in Swaps * Temporarily decrese Jest threshold for functions
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
import React from 'react';
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import {
|
|
renderWithProvider,
|
|
createSwapsMockStore,
|
|
} from '../../../../test/jest';
|
|
import SearchableItemList from '.';
|
|
|
|
const createProps = (customProps = {}) => {
|
|
return {
|
|
defaultToAll: true,
|
|
listTitle: 'listTitle',
|
|
itemsToSearch: [
|
|
{
|
|
iconUrl: 'iconUrl',
|
|
selected: true,
|
|
primaryLabel: 'primaryLabel',
|
|
secondaryLabel: 'secondaryLabel',
|
|
rightPrimaryLabel: 'rightPrimaryLabel',
|
|
rightSecondaryLabel: 'rightSecondaryLabel',
|
|
},
|
|
],
|
|
fuseSearchKeys: [
|
|
{
|
|
name: 'name',
|
|
weight: 0.499,
|
|
},
|
|
{
|
|
name: 'symbol',
|
|
weight: 0.499,
|
|
},
|
|
{
|
|
name: 'address',
|
|
weight: 0.002,
|
|
},
|
|
],
|
|
...customProps,
|
|
};
|
|
};
|
|
|
|
describe('SearchableItemList', () => {
|
|
it('renders the component with initial props', () => {
|
|
const store = configureMockStore()(createSwapsMockStore());
|
|
const props = createProps();
|
|
const { getByText } = renderWithProvider(
|
|
<SearchableItemList {...props} />,
|
|
store,
|
|
);
|
|
expect(getByText(props.listTitle)).toBeInTheDocument();
|
|
expect(getByText(props.itemsToSearch[0].primaryLabel)).toBeInTheDocument();
|
|
expect(
|
|
getByText(props.itemsToSearch[0].secondaryLabel),
|
|
).toBeInTheDocument();
|
|
expect(
|
|
getByText(props.itemsToSearch[0].rightPrimaryLabel),
|
|
).toBeInTheDocument();
|
|
expect(
|
|
getByText(props.itemsToSearch[0].rightSecondaryLabel),
|
|
).toBeInTheDocument();
|
|
expect(
|
|
document.querySelector('.searchable-item-list__search'),
|
|
).toMatchSnapshot();
|
|
expect(
|
|
document.querySelector('.searchable-item-list__item'),
|
|
).toMatchSnapshot();
|
|
});
|
|
});
|