mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
d1cea85f33
* Rename `provider` to `providerConfig` The network controller `provider` state has been renamed to `providerConfig`. This better reflects what this state is, and makes this controller more closely aligned with the core network controller. All references to the provider configuration have been updated to prefer `providerConfig` over `provider`, to make the distinction clear between a provider and provider config. Closes #18902 * Add migration
84 lines
2.3 KiB
JavaScript
84 lines
2.3 KiB
JavaScript
import React from 'react';
|
|
import { hexToDecimal } from '../../../../shared/modules/conversion.utils';
|
|
|
|
import mockState from '../../../../test/data/mock-state.json';
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
import configureStore from '../../../store/store';
|
|
import ConfirmSubTitle from './confirm-subtitle';
|
|
|
|
describe('ConfirmSubTitle', () => {
|
|
let store;
|
|
beforeEach(() => {
|
|
mockState.metamask.preferences.showFiatInTestnets = true;
|
|
store = configureStore(mockState);
|
|
});
|
|
|
|
it('should render subtitle correctly', async () => {
|
|
const { findByText } = renderWithProvider(
|
|
<ConfirmSubTitle
|
|
txData={{
|
|
txParams: {},
|
|
}}
|
|
hexTransactionAmount="0x9184e72a000"
|
|
/>,
|
|
store,
|
|
);
|
|
expect(await findByText('$0.01')).toBeInTheDocument();
|
|
});
|
|
|
|
it('should return null if showFiatInTestnets preference if false', () => {
|
|
mockState.metamask.preferences.showFiatInTestnets = false;
|
|
store = configureStore(mockState);
|
|
|
|
const { container } = renderWithProvider(
|
|
<ConfirmSubTitle
|
|
txData={{
|
|
txParams: {},
|
|
}}
|
|
hexTransactionAmount="0x9184e72a000"
|
|
/>,
|
|
store,
|
|
);
|
|
expect(container.firstChild).toStrictEqual(null);
|
|
});
|
|
|
|
it('should not null if showFiatInTestnets preference if false but it is NFT Transfer', async () => {
|
|
mockState.metamask.preferences.showFiatInTestnets = false;
|
|
mockState.metamask.allNftContracts = {
|
|
[mockState.metamask.selectedAddress]: {
|
|
[hexToDecimal(mockState.metamask.providerConfig.chainId)]: [
|
|
{ address: '0x9' },
|
|
],
|
|
},
|
|
};
|
|
store = configureStore(mockState);
|
|
|
|
const { findByText } = renderWithProvider(
|
|
<ConfirmSubTitle
|
|
txData={{
|
|
txParams: {
|
|
to: '0x9',
|
|
},
|
|
}}
|
|
hexTransactionAmount="0x9184e72a000"
|
|
/>,
|
|
store,
|
|
);
|
|
expect(await findByText('0.00001')).toBeInTheDocument();
|
|
});
|
|
|
|
it('should render subtitleComponent if passed', () => {
|
|
const { getByText } = renderWithProvider(
|
|
<ConfirmSubTitle
|
|
txData={{
|
|
txParams: {},
|
|
}}
|
|
hexTransactionAmount="0x9184e72a000"
|
|
subtitleComponent={<div>dummy_sub_title_passed</div>}
|
|
/>,
|
|
store,
|
|
);
|
|
expect(getByText('dummy_sub_title_passed')).toBeInTheDocument();
|
|
});
|
|
});
|