2021-11-23 17:52:50 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { screen } from '@testing-library/react';
|
|
|
|
|
|
|
|
import { renderWithProvider } from '../../../../../test/jest';
|
|
|
|
import { ETH } from '../../../../helpers/constants/common';
|
|
|
|
import { GasFeeContextProvider } from '../../../../contexts/gasFee';
|
|
|
|
import configureStore from '../../../../store/store';
|
|
|
|
|
|
|
|
import NetworkStatus from './network-status';
|
|
|
|
|
|
|
|
jest.mock('../../../../store/actions', () => ({
|
|
|
|
disconnectGasFeeEstimatePoller: jest.fn(),
|
|
|
|
getGasFeeEstimatesAndStartPolling: jest
|
|
|
|
.fn()
|
|
|
|
.mockImplementation(() => Promise.resolve()),
|
|
|
|
addPollingTokenToAppState: jest.fn(),
|
|
|
|
getGasFeeTimeEstimate: jest
|
|
|
|
.fn()
|
|
|
|
.mockImplementation(() => Promise.resolve('unknown')),
|
|
|
|
}));
|
|
|
|
|
|
|
|
const MOCK_FEE_ESTIMATE = {
|
|
|
|
estimatedBaseFee: '50.0112',
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderComponent = (props) => {
|
|
|
|
const store = configureStore({
|
|
|
|
metamask: {
|
|
|
|
nativeCurrency: ETH,
|
|
|
|
provider: {},
|
|
|
|
cachedBalances: {},
|
|
|
|
accounts: {
|
|
|
|
'0xAddress': {
|
|
|
|
address: '0xAddress',
|
|
|
|
balance: '0x176e5b6f173ebe66',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
selectedAddress: '0xAddress',
|
|
|
|
featureFlags: { advancedInlineGas: true },
|
|
|
|
gasFeeEstimates: MOCK_FEE_ESTIMATE,
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return renderWithProvider(
|
|
|
|
<GasFeeContextProvider>
|
|
|
|
<NetworkStatus />
|
|
|
|
</GasFeeContextProvider>,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('NetworkStatus', () => {
|
|
|
|
it('should renders labels', () => {
|
|
|
|
renderComponent();
|
|
|
|
expect(screen.queryByText('Base fee')).toBeInTheDocument();
|
|
|
|
expect(screen.queryByText('Priority fee')).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
2021-11-24 18:02:53 +01:00
|
|
|
it('should renders current base fee value', () => {
|
2021-11-23 17:52:50 +01:00
|
|
|
renderComponent();
|
|
|
|
expect(
|
2021-11-24 18:02:53 +01:00
|
|
|
screen.queryByText(`${MOCK_FEE_ESTIMATE.estimatedBaseFee} GWEI`),
|
2021-11-23 17:52:50 +01:00
|
|
|
).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
});
|