mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Unit tests improvements (#15517)
This commit is contained in:
parent
eb85fc266d
commit
5b63c7adf3
@ -8,7 +8,44 @@
|
||||
"context": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
|
||||
}
|
||||
},
|
||||
"history": {
|
||||
"mostRecentOverviewPage": "/"
|
||||
},
|
||||
"metamask": {
|
||||
"gasFeeEstimates": {
|
||||
"low": {
|
||||
"suggestedMaxPriorityFeePerGas": "1.233864249",
|
||||
"suggestedMaxFeePerGas": "19.308202033",
|
||||
"minWaitTimeEstimate": 15000,
|
||||
"maxWaitTimeEstimate": 30000
|
||||
},
|
||||
"medium": {
|
||||
"suggestedMaxPriorityFeePerGas": "1.5",
|
||||
"suggestedMaxFeePerGas": "25.900356008",
|
||||
"minWaitTimeEstimate": 15000,
|
||||
"maxWaitTimeEstimate": 45000
|
||||
},
|
||||
"high": {
|
||||
"suggestedMaxPriorityFeePerGas": "2",
|
||||
"suggestedMaxFeePerGas": "32.726374232",
|
||||
"minWaitTimeEstimate": 15000,
|
||||
"maxWaitTimeEstimate": 60000
|
||||
},
|
||||
"estimatedBaseFee": "18.074337783",
|
||||
"historicalBaseFeeRange": ["10.621659703", "19.673392581"],
|
||||
"baseFeeTrend": "up",
|
||||
"latestPriorityFeeRange": ["1.5", "17.536644176"],
|
||||
"historicalPriorityFeeRange": ["0.110624865", "718.303816711"],
|
||||
"priorityFeeTrend": "up",
|
||||
"networkCongestion": 0.87115
|
||||
},
|
||||
"preferences": {
|
||||
"hideZeroBalanceTokens": false,
|
||||
"showFiatInTestnets": false,
|
||||
"showTestNetworks": true,
|
||||
"useNativeCurrencyAsPrimaryCurrency": true
|
||||
},
|
||||
"ensResolutionsByAddress": {},
|
||||
"featureFlags": {
|
||||
"showIncomingTransactions": true
|
||||
},
|
||||
@ -37,6 +74,8 @@
|
||||
"1559": true
|
||||
}
|
||||
},
|
||||
"frequentRpcListDetail": [],
|
||||
"subjectMetadata": {},
|
||||
"notifications": {
|
||||
"test": {
|
||||
"id": "test",
|
||||
|
@ -93,9 +93,11 @@ export function renderWithProvider(component, store, pathname = '/') {
|
||||
</Router>
|
||||
</Provider>
|
||||
) : (
|
||||
<Router history={history}>
|
||||
<LegacyI18nProvider>
|
||||
<LegacyMetaMetricsProvider>{children}</LegacyMetaMetricsProvider>
|
||||
</LegacyI18nProvider>
|
||||
</Router>
|
||||
);
|
||||
|
||||
Wrapper.propTypes = {
|
||||
|
@ -0,0 +1,53 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Import Token Link should match snapshot for mainnet chainId 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="box import-token-link box--flex-direction-row box--text-align-center"
|
||||
>
|
||||
<a
|
||||
class="button btn-link import-token-link__link"
|
||||
data-testid="refresh-list-button"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Refresh list
|
||||
</a>
|
||||
or
|
||||
<a
|
||||
class="button btn-link import-token-link__link"
|
||||
data-testid="import-token-button"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
import tokens
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Import Token Link should match snapshot for rinkeby chainId 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="box import-token-link box--flex-direction-row box--text-align-center"
|
||||
>
|
||||
<a
|
||||
class="button btn-link import-token-link__link"
|
||||
data-testid="refresh-list-button"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Refresh list
|
||||
</a>
|
||||
or
|
||||
<a
|
||||
class="button btn-link import-token-link__link"
|
||||
data-testid="import-token-button"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
import tokens
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
@ -35,6 +35,7 @@ export default function ImportTokenLink() {
|
||||
<>
|
||||
<Button
|
||||
className="import-token-link__link"
|
||||
data-testid="refresh-list-button"
|
||||
type="link"
|
||||
onClick={() => detectNewTokens()}
|
||||
>
|
||||
@ -45,6 +46,7 @@ export default function ImportTokenLink() {
|
||||
)}
|
||||
<Button
|
||||
className="import-token-link__link"
|
||||
data-testid="import-token-button"
|
||||
type="link"
|
||||
onClick={() => {
|
||||
history.push(IMPORT_TOKEN_ROUTE);
|
||||
|
@ -0,0 +1,95 @@
|
||||
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 ImportTokenLink from '.';
|
||||
|
||||
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.js', () => ({
|
||||
detectNewTokens: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('Import Token Link', () => {
|
||||
it('should match snapshot for rinkeby chainId', () => {
|
||||
const mockState = {
|
||||
metamask: {
|
||||
provider: {
|
||||
chainId: '0x4',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const store = configureMockStore()(mockState);
|
||||
|
||||
const { container } = renderWithProvider(<ImportTokenLink />, store);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should match snapshot for mainnet chainId', () => {
|
||||
const mockState = {
|
||||
metamask: {
|
||||
provider: {
|
||||
chainId: '0x1',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const store = configureMockStore()(mockState);
|
||||
|
||||
const { container } = renderWithProvider(<ImportTokenLink />, store);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should detectNewTokens when clicking refresh', () => {
|
||||
const mockState = {
|
||||
metamask: {
|
||||
provider: {
|
||||
chainId: '0x4',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const store = configureMockStore()(mockState);
|
||||
|
||||
renderWithProvider(<ImportTokenLink />, 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: '0x4',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const store = configureMockStore()(mockState);
|
||||
|
||||
renderWithProvider(<ImportTokenLink />, store);
|
||||
|
||||
const importToken = screen.getByTestId('import-token-button');
|
||||
fireEvent.click(importToken);
|
||||
|
||||
expect(mockPushHistory).toHaveBeenCalledWith('/import-token');
|
||||
});
|
||||
});
|
@ -0,0 +1,225 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`SignatureRequestOriginal should match snapshot 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="request-signature__container"
|
||||
>
|
||||
<div
|
||||
class="request-signature__header"
|
||||
>
|
||||
<div
|
||||
class="request-signature__header-background"
|
||||
/>
|
||||
<div
|
||||
class="request-signature__header__text"
|
||||
>
|
||||
Signature request
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__header__tip-container"
|
||||
>
|
||||
<div
|
||||
class="request-signature__header__tip"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__body"
|
||||
>
|
||||
<div
|
||||
class="request-signature__account-info"
|
||||
>
|
||||
<div
|
||||
class="request-signature__account"
|
||||
>
|
||||
<div
|
||||
class="request-signature__account-text"
|
||||
>
|
||||
Account:
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__account-item"
|
||||
>
|
||||
<div
|
||||
class="account-list-item undefined"
|
||||
>
|
||||
<div
|
||||
class="account-list-item__top-row"
|
||||
>
|
||||
<div
|
||||
class=""
|
||||
>
|
||||
<div
|
||||
class="identicon account-list-item__identicon"
|
||||
style="height: 18px; width: 18px; border-radius: 9px;"
|
||||
>
|
||||
<div
|
||||
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 18px; height: 18px; display: inline-block; background: rgb(250, 58, 0);"
|
||||
>
|
||||
<svg
|
||||
height="18"
|
||||
width="18"
|
||||
x="0"
|
||||
y="0"
|
||||
>
|
||||
<rect
|
||||
fill="#18CDF2"
|
||||
height="18"
|
||||
transform="translate(-0.5897213458840913 -1.8586597890715306) rotate(328.9 9 9)"
|
||||
width="18"
|
||||
x="0"
|
||||
y="0"
|
||||
/>
|
||||
<rect
|
||||
fill="#035E56"
|
||||
height="18"
|
||||
transform="translate(-10.292884711218024 5.9582598028585885) rotate(176.2 9 9)"
|
||||
width="18"
|
||||
x="0"
|
||||
y="0"
|
||||
/>
|
||||
<rect
|
||||
fill="#F26602"
|
||||
height="18"
|
||||
transform="translate(9.375661135250958 -7.990391094185859) rotate(468.9 9 9)"
|
||||
width="18"
|
||||
x="0"
|
||||
y="0"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="account-list-item__account-name"
|
||||
>
|
||||
Test Account
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__request-icon"
|
||||
>
|
||||
<div
|
||||
class="identicon__image-border"
|
||||
style="height: 40px; width: 40px; border-radius: 20px;"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__balance"
|
||||
>
|
||||
<div
|
||||
class="request-signature__balance-text"
|
||||
>
|
||||
Balance:
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__balance-value"
|
||||
>
|
||||
0 ETH
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__origin-row"
|
||||
>
|
||||
<div
|
||||
class="request-signature__origin-label"
|
||||
>
|
||||
Origin:
|
||||
</div>
|
||||
<div
|
||||
class="site-origin request-signature__origin"
|
||||
>
|
||||
<span>
|
||||
https://happydapp.website/governance?futarchy=true
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__notice request-signature__warning"
|
||||
>
|
||||
Signing this message can be dangerous. This signature could potentially perform any operation on your account's behalf, including granting complete control of your account and all of its assets to the requesting site. Only sign this message if you know what you're doing or completely trust the requesting site.
|
||||
<span
|
||||
class="request-signature__help-link"
|
||||
>
|
||||
Learn more
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__rows"
|
||||
>
|
||||
<div
|
||||
class="request-signature__row"
|
||||
>
|
||||
<div
|
||||
class="request-signature__row-title"
|
||||
>
|
||||
Message:
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__row-value"
|
||||
>
|
||||
{"domain":{"name":"happydapp.website"},"message":{"string":"haay wuurl","number":42},"primaryType":"Mail","types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Group":[{"name":"name","type":"string"},{"name":"members","type":"Person[]"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person[]"},{"name":"contents","type":"string"}],"Person":[{"name":"name","type":"string"},{"name":"wallets","type":"address[]"}]}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="confirm-approve-content__ledger-instruction-wrapper"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
class="confirm-detail-row"
|
||||
>
|
||||
<div
|
||||
class="dialog dialog--message"
|
||||
>
|
||||
<div
|
||||
class="ledger-live-dialog"
|
||||
>
|
||||
<h6
|
||||
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography typography--h7 typography--weight-bold typography--style-normal typography--color-text-default"
|
||||
>
|
||||
Prior to clicking confirm:
|
||||
</h6>
|
||||
<h6
|
||||
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography typography--h7 typography--weight-bold typography--style-normal typography--color-text-default"
|
||||
>
|
||||
- Plug in your Ledger device and select the Ethereum app
|
||||
</h6>
|
||||
<h6
|
||||
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography typography--h7 typography--weight-bold typography--style-normal typography--color-text-default"
|
||||
>
|
||||
- Enable "smart contract data" or "blind signing" on your Ledger device
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="request-signature__footer"
|
||||
>
|
||||
<button
|
||||
class="button btn--rounded btn-secondary btn--large request-signature__footer__cancel-button"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
class="button btn--rounded btn-primary btn--large request-signature__footer__sign-button"
|
||||
data-testid="request-signature__sign"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Sign
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
@ -0,0 +1,64 @@
|
||||
import React from 'react';
|
||||
import configureMockStore from 'redux-mock-store';
|
||||
import { MESSAGE_TYPE } from '../../../../shared/constants/app';
|
||||
import mockState from '../../../../test/data/mock-state.json';
|
||||
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
||||
import SignatureRequestOriginal from '.';
|
||||
|
||||
const MOCK_SIGN_DATA = JSON.stringify({
|
||||
domain: {
|
||||
name: 'happydapp.website',
|
||||
},
|
||||
message: {
|
||||
string: 'haay wuurl',
|
||||
number: 42,
|
||||
},
|
||||
primaryType: 'Mail',
|
||||
types: {
|
||||
EIP712Domain: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'version', type: 'string' },
|
||||
{ name: 'chainId', type: 'uint256' },
|
||||
{ name: 'verifyingContract', type: 'address' },
|
||||
],
|
||||
Group: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'members', type: 'Person[]' },
|
||||
],
|
||||
Mail: [
|
||||
{ name: 'from', type: 'Person' },
|
||||
{ name: 'to', type: 'Person[]' },
|
||||
{ name: 'contents', type: 'string' },
|
||||
],
|
||||
Person: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'wallets', type: 'address[]' },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
describe('SignatureRequestOriginal', () => {
|
||||
const store = configureMockStore()(mockState);
|
||||
|
||||
it('should match snapshot', () => {
|
||||
const props = {
|
||||
signMessage: jest.fn(),
|
||||
cancelMessage: jest.fn(),
|
||||
txData: {
|
||||
msgParams: {
|
||||
from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||
data: MOCK_SIGN_DATA,
|
||||
origin: 'https://happydapp.website/governance?futarchy=true',
|
||||
},
|
||||
type: MESSAGE_TYPE.ETH_SIGN,
|
||||
},
|
||||
};
|
||||
|
||||
const { container } = renderWithProvider(
|
||||
<SignatureRequestOriginal {...props} />,
|
||||
store,
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
});
|
@ -0,0 +1,203 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`SeedPhrase Component should match snapshot 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="first-time-flow__wrapper "
|
||||
>
|
||||
<div
|
||||
class="app-header__logo-container"
|
||||
>
|
||||
<svg
|
||||
class="app-header__metafox-logo--horizontal"
|
||||
height="30"
|
||||
viewBox="0 0 1311 242"
|
||||
width="162"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
>
|
||||
<g
|
||||
fill="var(--color-text-default)"
|
||||
transform="translate(361 61)"
|
||||
>
|
||||
<path
|
||||
d="m796.7 60.9c-6.8-4.5-14.3-7.7-21.4-11.7-4.6-2.6-9.5-4.9-13.5-8.2-6.8-5.6-5.4-16.6 1.7-21.4 10.2-6.8 27.1-3 28.9 10.9 0 .3.3.5.6.5h15.4c.4 0 .7-.3.6-.7-.8-9.6-4.5-17.6-11.3-22.7-6.5-4.9-13.9-7.5-21.8-7.5-40.7 0-44.4 43.1-22.5 56.7 2.5 1.6 24 12.4 31.6 17.1s10 13.3 6.7 20.1c-3 6.2-10.8 10.5-18.6 10-8.5-.5-15.1-5.1-17.4-12.3-.4-1.3-.6-3.8-.6-4.9 0-.3-.3-.6-.6-.6h-16.7c-.3 0-.6.3-.6.6 0 12.1 3 18.8 11.2 24.9 7.7 5.8 16.1 8.2 24.8 8.2 22.8 0 34.6-12.9 37-26.3 2.1-13.1-1.8-24.9-13.5-32.7z"
|
||||
/>
|
||||
<path
|
||||
d="m71.6 2.3h-7.4-8.1c-.3 0-.5.2-.6.4l-13.7 45.2c-.2.6-1 .6-1.2 0l-13.7-45.2c-.1-.3-.3-.4-.6-.4h-8.1-7.4-10c-.3 0-.6.3-.6.6v115.4c0 .3.3.6.6.6h16.7c.3 0 .6-.3.6-.6v-87.7c0-.7 1-.8 1.2-.2l13.8 45.5 1 3.2c.1.3.3.4.6.4h12.8c.3 0 .5-.2.6-.4l1-3.2 13.8-45.5c.2-.7 1.2-.5 1.2.2v87.7c0 .3.3.6.6.6h16.7c.3 0 .6-.3.6-.6v-115.4c0-.3-.3-.6-.6-.6z"
|
||||
/>
|
||||
<path
|
||||
d="m541 2.3c-.3 0-.5.2-.6.4l-13.7 45.2c-.2.6-1 .6-1.2 0l-13.7-45.2c-.1-.3-.3-.4-.6-.4h-25.4c-.3 0-.6.3-.6.6v115.4c0 .3.3.6.6.6h16.7c.3 0 .6-.3.6-.6v-87.7c0-.7 1-.8 1.2-.2l13.8 45.5 1 3.2c.1.3.3.4.6.4h12.8c.3 0 .5-.2.6-.4l1-3.2 13.8-45.5c.2-.7 1.2-.5 1.2.2v87.7c0 .3.3.6.6.6h16.7c.3 0 .6-.3.6-.6v-115.4c0-.3-.3-.6-.6-.6z"
|
||||
/>
|
||||
<path
|
||||
d="m325.6 2.3h-31.1-16.7-31.1c-.3 0-.6.3-.6.6v14.4c0 .3.3.6.6.6h30.5v100.4c0 .3.3.6.6.6h16.7c.3 0 .6-.3.6-.6v-100.4h30.5c.3 0 .6-.3.6-.6v-14.4c0-.3-.2-.6-.6-.6z"
|
||||
/>
|
||||
<path
|
||||
d="m424.1 118.9h15.2c.4 0 .7-.4.6-.8l-31.4-115.8c-.1-.3-.3-.4-.6-.4h-5.8-10.2-5.8c-.3 0-.5.2-.6.4l-31.4 115.8c-.1.4.2.8.6.8h15.2c.3 0 .5-.2.6-.4l9.1-33.7c.1-.3.3-.4.6-.4h33.6c.3 0 .5.2.6.4l9.1 33.7c.1.2.4.4.6.4zm-39.9-51 12.2-45.1c.2-.6 1-.6 1.2 0l12.2 45.1c.1.4-.2.8-.6.8h-24.4c-.4 0-.7-.4-.6-.8z"
|
||||
/>
|
||||
<path
|
||||
d="m683.3 118.9h15.2c.4 0 .7-.4.6-.8l-31.4-115.8c-.1-.3-.3-.4-.6-.4h-5.8-10.2-5.8c-.3 0-.5.2-.6.4l-31.4 115.8c-.1.4.2.8.6.8h15.2c.3 0 .5-.2.6-.4l9.1-33.7c.1-.3.3-.4.6-.4h33.6c.3 0 .5.2.6.4l9.1 33.7c.1.2.3.4.6.4zm-39.9-51 12.2-45.1c.2-.6 1-.6 1.2 0l12.2 45.1c.1.4-.2.8-.6.8h-24.4c-.4 0-.7-.4-.6-.8z"
|
||||
/>
|
||||
<path
|
||||
d="m149.8 101.8v-35.8c0-.3.3-.6.6-.6h44.5c.3 0 .6-.3.6-.6v-14.4c0-.3-.3-.6-.6-.6h-44.5c-.3 0-.6-.3-.6-.6v-30.6c0-.3.3-.6.6-.6h50.6c.3 0 .6-.3.6-.6v-14.4c0-.3-.3-.6-.6-.6h-51.2-17.3c-.3 0-.6.3-.6.6v15 31.9 15.6 37 15.8c0 .3.3.6.6.6h17.3 53.3c.3 0 .6-.3.6-.6v-15.2c0-.3-.3-.6-.6-.6h-52.8c-.3-.1-.5-.3-.5-.7z"
|
||||
/>
|
||||
<path
|
||||
d="m949.3 117.9-57.8-59.7c-.2-.2-.2-.6 0-.8l52-54c.4-.4.1-1-.4-1h-21.3c-.2 0-.3.1-.4.2l-44.1 45.8c-.4.4-1 .1-1-.4v-45c0-.3-.3-.6-.6-.6h-16.7c-.3 0-.6.3-.6.6v115.4c0 .3.3.6.6.6h16.7c.3 0 .6-.3.6-.6v-50.8c0-.5.7-.8 1-.4l50 51.6c.1.1.3.2.4.2h21.3c.4-.1.7-.8.3-1.1z"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
transform="translate(1 1)"
|
||||
>
|
||||
<path
|
||||
d="m246.1.2-101.1 75 18.8-44.2z"
|
||||
fill="#e17726"
|
||||
stroke="#e17726"
|
||||
/>
|
||||
<g
|
||||
fill="#e27625"
|
||||
stroke="#e27625"
|
||||
transform="translate(2)"
|
||||
>
|
||||
<path
|
||||
d="m10.9.2 100.2 75.7-17.9-44.9z"
|
||||
/>
|
||||
<path
|
||||
d="m207.7 174.1-26.9 41.2 57.6 15.9 16.5-56.2z"
|
||||
/>
|
||||
<path
|
||||
d="m.2 175 16.4 56.2 57.5-15.9-26.8-41.2z"
|
||||
/>
|
||||
<path
|
||||
d="m71 104.5-16 24.2 57 2.6-1.9-61.5z"
|
||||
/>
|
||||
<path
|
||||
d="m184 104.5-39.7-35.4-1.3 62.2 57-2.6z"
|
||||
/>
|
||||
<path
|
||||
d="m74.1 215.3 34.5-16.7-29.7-23.2z"
|
||||
/>
|
||||
<path
|
||||
d="m146.4 198.6 34.4 16.7-4.7-39.9z"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
fill="#d5bfb2"
|
||||
stroke="#d5bfb2"
|
||||
transform="translate(76 198)"
|
||||
>
|
||||
<path
|
||||
d="m106.8 17.3-34.4-16.7 2.8 22.4-.3 9.5z"
|
||||
/>
|
||||
<path
|
||||
d="m.1 17.3 32 15.2-.2-9.5 2.7-22.4z"
|
||||
/>
|
||||
</g>
|
||||
<path
|
||||
d="m108.7 160.6-28.6-8.4 20.2-9.3z"
|
||||
fill="#233447"
|
||||
stroke="#233447"
|
||||
/>
|
||||
<path
|
||||
d="m150.3 160.6 8.4-17.7 20.3 9.3z"
|
||||
fill="#233447"
|
||||
stroke="#233447"
|
||||
/>
|
||||
<g
|
||||
fill="#cc6228"
|
||||
stroke="#cc6228"
|
||||
transform="translate(49 128)"
|
||||
>
|
||||
<path
|
||||
d="m27.1 87.3 5-41.2-31.8.9z"
|
||||
/>
|
||||
<path
|
||||
d="m128.9 46.1 4.9 41.2 26.9-40.3z"
|
||||
/>
|
||||
<path
|
||||
d="m153 .7-57 2.6 5.3 29.3 8.4-17.7 20.3 9.3z"
|
||||
/>
|
||||
<path
|
||||
d="m31.1 24.2 20.2-9.3 8.4 17.7 5.3-29.3-57-2.6z"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
fill="#e27525"
|
||||
stroke="#e27525"
|
||||
transform="translate(57 128)"
|
||||
>
|
||||
<path
|
||||
d="m0 .7 23.9 46.7-.8-23.2z"
|
||||
/>
|
||||
<path
|
||||
d="m122 24.2-.9 23.2 23.9-46.7z"
|
||||
/>
|
||||
<path
|
||||
d="m57 3.3-5.3 29.3 6.7 34.6 1.5-45.6z"
|
||||
/>
|
||||
<path
|
||||
d="m88 3.3-2.8 18.2 1.4 45.7 6.7-34.6z"
|
||||
/>
|
||||
</g>
|
||||
<path
|
||||
d="m150.3 160.6-6.7 34.6 4.8 3.4 29.7-23.2.9-23.2z"
|
||||
fill="#f5841f"
|
||||
stroke="#f5841f"
|
||||
/>
|
||||
<path
|
||||
d="m80.1 152.2.8 23.2 29.7 23.2 4.8-3.4-6.7-34.6z"
|
||||
fill="#f5841f"
|
||||
stroke="#f5841f"
|
||||
/>
|
||||
<path
|
||||
d="m150.9 230.5.3-9.5-2.6-2.2h-38.2l-2.5 2.2.2 9.5-32-15.2 11.2 9.2 22.7 15.7h38.9l22.8-15.7 11.1-9.2z"
|
||||
fill="#c0ac9d"
|
||||
stroke="#c0ac9d"
|
||||
/>
|
||||
<path
|
||||
d="m148.4 198.6-4.8-3.4h-28.2l-4.8 3.4-2.7 22.4 2.5-2.2h38.2l2.6 2.2z"
|
||||
fill="#161616"
|
||||
stroke="#161616"
|
||||
/>
|
||||
<g
|
||||
fill="#763e1a"
|
||||
stroke="#763e1a"
|
||||
>
|
||||
<path
|
||||
d="m250.4 80.1 8.5-41.4-12.8-38.5-97.7 72.5 37.6 31.8 53.1 15.5 11.7-13.7-5.1-3.7 8.1-7.4-6.2-4.8 8.1-6.2z"
|
||||
/>
|
||||
<path
|
||||
d="m.1 38.7 8.6 41.4-5.5 4.1 8.2 6.2-6.2 4.8 8.1 7.4-5.1 3.7 11.7 13.7 53.1-15.5 37.6-31.8-97.7-72.5z"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
fill="#f5841f"
|
||||
stroke="#f5841f"
|
||||
>
|
||||
<path
|
||||
d="m239.1 120-53.1-15.5 16 24.2-23.9 46.7 31.6-.4h47.2z"
|
||||
/>
|
||||
<path
|
||||
d="m73 104.5-53.1 15.5-17.7 55h47.1l31.6.4-23.9-46.7z"
|
||||
/>
|
||||
<path
|
||||
d="m145 131.3 3.4-58.6 15.4-41.7h-68.6l15.4 41.7 3.4 58.6 1.3 18.4.1 45.5h28.2l.1-45.5z"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<img
|
||||
alt=""
|
||||
class="app-header__metafox-logo--icon"
|
||||
height="42"
|
||||
src="./images/logo/metamask-fox.svg"
|
||||
width="42"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
@ -130,7 +130,7 @@ export default class ConfirmSeedPhrase extends PureComponent {
|
||||
this.state;
|
||||
|
||||
return (
|
||||
<div className="confirm-seed-phrase">
|
||||
<div className="confirm-seed-phrase" data-testid="confirm-seed-phrase">
|
||||
<div className="confirm-seed-phrase__back-button">
|
||||
<a
|
||||
onClick={(e) => {
|
||||
|
@ -148,7 +148,7 @@ export default class RevealSeedPhrase extends PureComponent {
|
||||
const { history, onboardingInitiator } = this.props;
|
||||
|
||||
return (
|
||||
<div className="reveal-seed-phrase">
|
||||
<div className="reveal-seed-phrase" data-testid="reveal-seed-phrase">
|
||||
<div className="seed-phrase__sections">
|
||||
<div className="seed-phrase__main">
|
||||
<Box marginBottom={4}>
|
||||
|
@ -43,7 +43,7 @@ export default function SeedPhraseIntro() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="seed-phrase-intro">
|
||||
<div className="seed-phrase-intro" data-testid="seed-phrase-intro">
|
||||
<div className="seed-phrase-intro__sections">
|
||||
<div className="seed-phrase-intro__left">
|
||||
<Typography
|
||||
|
127
ui/pages/first-time-flow/seed-phrase/seed-phrase.test.js
Normal file
127
ui/pages/first-time-flow/seed-phrase/seed-phrase.test.js
Normal file
@ -0,0 +1,127 @@
|
||||
import React from 'react';
|
||||
import sinon from 'sinon';
|
||||
import configureMockStore from 'redux-mock-store';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
||||
import {
|
||||
INITIALIZE_SEED_PHRASE_ROUTE,
|
||||
INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE,
|
||||
INITIALIZE_BACKUP_SEED_PHRASE_ROUTE,
|
||||
INITIALIZE_SEED_PHRASE_INTRO_ROUTE,
|
||||
} from '../../../helpers/constants/routes';
|
||||
import SeedPhrase from '.';
|
||||
|
||||
describe('SeedPhrase Component', () => {
|
||||
afterEach(() => {
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
it('should match snapshot', () => {
|
||||
const props = {
|
||||
history: {
|
||||
push: sinon.stub(),
|
||||
},
|
||||
verifySeedPhrase: sinon.stub().resolves('verifed seed'),
|
||||
};
|
||||
|
||||
const { container } = renderWithProvider(<SeedPhrase {...props} />);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render confirm seed phrase component with seed-phrase/confirm route', () => {
|
||||
const mockState = {
|
||||
metamask: {},
|
||||
};
|
||||
|
||||
const store = configureMockStore()(mockState);
|
||||
const props = {
|
||||
history: {
|
||||
push: sinon.stub(),
|
||||
},
|
||||
verifySeedPhrase: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
renderWithProvider(
|
||||
<SeedPhrase {...props} />,
|
||||
store,
|
||||
INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE,
|
||||
);
|
||||
|
||||
const confirmSeedPhrase = screen.queryByTestId('confirm-seed-phrase');
|
||||
expect(confirmSeedPhrase).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render reveal-seed-phrase component with /seed-phrase route', () => {
|
||||
const mockState = {
|
||||
metamask: {},
|
||||
};
|
||||
|
||||
const store = configureMockStore()(mockState);
|
||||
const props = {
|
||||
history: {
|
||||
push: sinon.stub(),
|
||||
},
|
||||
verifySeedPhrase: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
renderWithProvider(
|
||||
<SeedPhrase {...props} />,
|
||||
store,
|
||||
INITIALIZE_SEED_PHRASE_ROUTE,
|
||||
);
|
||||
|
||||
const confirmSeedPhrase = screen.queryByTestId('reveal-seed-phrase');
|
||||
expect(confirmSeedPhrase).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render reveal-seed-phrase component with /backup-seed-phrase route', () => {
|
||||
const mockState = {
|
||||
metamask: {
|
||||
onboardingTabs: [],
|
||||
},
|
||||
};
|
||||
|
||||
const store = configureMockStore()(mockState);
|
||||
const props = {
|
||||
history: {
|
||||
push: sinon.stub(),
|
||||
},
|
||||
verifySeedPhrase: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
renderWithProvider(
|
||||
<SeedPhrase {...props} />,
|
||||
store,
|
||||
INITIALIZE_BACKUP_SEED_PHRASE_ROUTE,
|
||||
);
|
||||
|
||||
const confirmSeedPhrase = screen.queryByTestId('reveal-seed-phrase');
|
||||
expect(confirmSeedPhrase).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render reveal-seed-phrase component with /seed-phrase-intro route', () => {
|
||||
const mockState = {
|
||||
metamask: {
|
||||
onboardingTabs: [],
|
||||
},
|
||||
};
|
||||
|
||||
const store = configureMockStore()(mockState);
|
||||
const props = {
|
||||
history: {
|
||||
push: sinon.stub(),
|
||||
},
|
||||
verifySeedPhrase: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
renderWithProvider(
|
||||
<SeedPhrase {...props} />,
|
||||
store,
|
||||
INITIALIZE_SEED_PHRASE_INTRO_ROUTE,
|
||||
);
|
||||
|
||||
const seedPhraseIntro = screen.queryByTestId('seed-phrase-intro');
|
||||
expect(seedPhraseIntro).toBeInTheDocument();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user