mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 12:56:01 +01:00
0bbcbe6e90
* Update mock state data * Convert App Header test to tlr. * Convert Gas Timing test to tlr. * Convert Account Details Modal to tlr. * Update Sig Req test to match mock state changes. * Add test-ids to Editable Label for Account Details Modal * Adjust selectors test for the mock state update. * Add back gasIsLoading for selectors test.
82 lines
2.1 KiB
JavaScript
82 lines
2.1 KiB
JavaScript
import React from 'react';
|
|
import configureMockStore from 'redux-mock-store';
|
|
import { waitFor } from '@testing-library/react';
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
|
|
import { GAS_ESTIMATE_TYPES } from '../../../../shared/constants/gas';
|
|
import mockState from '../../../../test/data/mock-state.json';
|
|
|
|
import GasTiming from '.';
|
|
|
|
jest.mock('../../../store/actions.js', () => ({
|
|
getGasFeeTimeEstimate: jest.fn().mockImplementation(() => Promise.resolve()),
|
|
}));
|
|
|
|
describe('Gas timing', () => {
|
|
it('renders nothing when gas is loading', () => {
|
|
// Fails the networkAndAccountSupports1559 check
|
|
const nullGasState = {
|
|
metamask: {
|
|
gasFeeEstimates: null,
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.FEE_MARKET,
|
|
},
|
|
};
|
|
|
|
const mockStore = configureMockStore()(nullGasState);
|
|
|
|
const { container } = renderWithProvider(<GasTiming />, mockStore);
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it('renders "very likely" when high estimate is chosen', async () => {
|
|
const mockStore = configureMockStore()(mockState);
|
|
|
|
const props = {
|
|
maxPriorityFeePerGas: '10',
|
|
};
|
|
|
|
const { queryByText } = renderWithProvider(
|
|
<GasTiming {...props} />,
|
|
mockStore,
|
|
);
|
|
|
|
await waitFor(() => {
|
|
expect(queryByText(/Very likely in/u)).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
it('renders "likely" when medium estimate is chosen', async () => {
|
|
const mockStore = configureMockStore()(mockState);
|
|
|
|
const props = {
|
|
maxPriorityFeePerGas: '8',
|
|
};
|
|
|
|
const { queryByText } = renderWithProvider(
|
|
<GasTiming {...props} />,
|
|
mockStore,
|
|
);
|
|
|
|
await waitFor(() => {
|
|
expect(queryByText(/Likely in/u)).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
it('renders "maybe" when low estimate is chosen', async () => {
|
|
const mockStore = configureMockStore()(mockState);
|
|
|
|
const props = {
|
|
maxPriorityFeePerGas: '3',
|
|
};
|
|
|
|
const { queryByText } = renderWithProvider(
|
|
<GasTiming {...props} />,
|
|
mockStore,
|
|
);
|
|
|
|
await waitFor(() => {
|
|
expect(queryByText(/Maybe in/u)).toBeInTheDocument();
|
|
});
|
|
});
|
|
});
|