1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/ui/currency-display/currency-display.component.test.js
2021-04-28 14:53:59 -05:00

46 lines
1.2 KiB
JavaScript

import React from 'react';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import * as reactRedux from 'react-redux';
import CurrencyDisplay from './currency-display.component';
describe('CurrencyDisplay Component', () => {
beforeEach(() => {
const stub = sinon.stub(reactRedux, 'useSelector');
stub.callsFake(() => ({
currentCurrency: 'usd',
nativeCurrency: 'ETH',
conversionRate: 280.45,
}));
});
afterEach(() => {
sinon.restore();
});
it('should render text with a className', () => {
const wrapper = shallow(
<CurrencyDisplay
displayValue="$123.45"
className="currency-display"
hideLabel
/>,
);
expect(wrapper.hasClass('currency-display')).toStrictEqual(true);
expect(wrapper.text()).toStrictEqual('$123.45');
});
it('should render text with a prefix', () => {
const wrapper = shallow(
<CurrencyDisplay
displayValue="$123.45"
className="currency-display"
prefix="-"
hideLabel
/>,
);
expect(wrapper.hasClass('currency-display')).toStrictEqual(true);
expect(wrapper.text()).toStrictEqual('-$123.45');
});
});