Skip to content

Commit

Permalink
updating test
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanaBinoy committed Jan 16, 2023
1 parent 1ac87ae commit 8b96364
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions ui/pages/swaps/fee-card/fee-card.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { useSelector } from 'react-redux';

import {
renderWithProvider,
createSwapsMockStore,
setBackgroundConnection,
MOCKS,
fireEvent,
} from '../../../../test/jest';
import { CHAIN_IDS } from '../../../../shared/constants/network';

import { checkNetworkAndAccountSupports1559 } from '../../../selectors';
import {
checkNetworkAndAccountSupports1559,
getUseCurrencyRateCheck,
} from '../../../selectors';
import {
getGasEstimateType,
getGasFeeEstimates,
Expand All @@ -22,8 +22,6 @@ import { TRANSACTION_ENVELOPE_TYPE_NAMES } from '../../../helpers/constants/tran

import FeeCard from '.';

const middleware = [thunk];

jest.mock('../../../hooks/useGasFeeEstimates', () => ({
useGasFeeEstimates: jest.fn(),
}));
Expand All @@ -50,6 +48,9 @@ const generateUseSelectorRouter = () => (selector) => {
if (selector === getIsGasEstimatesLoading) {
return false;
}
if (selector === getUseCurrencyRateCheck) {
return true;
}
return undefined;
};

Expand Down Expand Up @@ -109,13 +110,12 @@ describe('FeeCard', () => {
});

it('renders the component with EIP-1559 enabled', () => {
const store = configureMockStore(middleware)(createSwapsMockStore());
const props = createProps({
networkAndAccountSupports1559: true,
maxPriorityFeePerGasDecGWEI: '3',
maxFeePerGasDecGWEI: '4',
});
const { getByText } = renderWithProvider(<FeeCard {...props} />, store);
const { getByText } = renderWithProvider(<FeeCard {...props} />);
expect(getByText('Best of 6 quotes.')).toBeInTheDocument();
expect(getByText('Estimated gas fee')).toBeInTheDocument();
expect(getByText('Max fee')).toBeInTheDocument();
Expand All @@ -129,7 +129,6 @@ describe('FeeCard', () => {
});

it('renders the component with smart transactions enabled and user opted in', () => {
const store = configureMockStore(middleware)(createSwapsMockStore());
const props = createProps({
smartTransactionsOptInStatus: true,
smartTransactionsEnabled: true,
Expand All @@ -138,7 +137,6 @@ describe('FeeCard', () => {
});
const { getByText, queryByTestId } = renderWithProvider(
<FeeCard {...props} />,
store,
);
expect(getByText('Best of 6 quotes.')).toBeInTheDocument();
expect(getByText('Estimated gas fee')).toBeInTheDocument();
Expand All @@ -149,20 +147,18 @@ describe('FeeCard', () => {
});

it('renders the component with hidden token approval row', () => {
const store = configureMockStore(middleware)(createSwapsMockStore());
const props = createProps({
hideTokenApprovalRow: true,
});
const { queryByText } = renderWithProvider(<FeeCard {...props} />, store);
const { queryByText } = renderWithProvider(<FeeCard {...props} />);
expect(queryByText('Edit limit')).not.toBeInTheDocument();
});

it('approves a token', () => {
const store = configureMockStore(middleware)(createSwapsMockStore());
const props = createProps({
onTokenApprovalClick: jest.fn(),
});
const { queryByText } = renderWithProvider(<FeeCard {...props} />, store);
const { queryByText } = renderWithProvider(<FeeCard {...props} />);
fireEvent.click(queryByText('Edit limit'));
expect(props.onTokenApprovalClick).toHaveBeenCalled();
});
Expand Down

0 comments on commit 8b96364

Please sign in to comment.