You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.5 KiB
42 lines
1.5 KiB
4 years ago
|
import React from 'react';
|
||
|
import { shallow } from 'enzyme';
|
||
|
import sinon from 'sinon';
|
||
4 years ago
|
import CurrencyDisplay from '../../ui/currency-display';
|
||
|
import * as currencyHook from '../../../hooks/useCurrencyDisplay';
|
||
|
import * as currencyPrefHook from '../../../hooks/useUserPreferencedCurrency';
|
||
|
import UserPreferencedCurrencyDisplay from './user-preferenced-currency-display.component';
|
||
5 years ago
|
|
||
4 years ago
|
describe('UserPreferencedCurrencyDisplay Component', () => {
|
||
|
describe('rendering', () => {
|
||
|
beforeEach(() => {
|
||
4 years ago
|
sinon.stub(currencyHook, 'useCurrencyDisplay').returns(['1', {}]);
|
||
4 years ago
|
sinon
|
||
|
.stub(currencyPrefHook, 'useUserPreferencedCurrency')
|
||
4 years ago
|
.returns({ currency: 'ETH', decimals: 6 });
|
||
|
});
|
||
4 years ago
|
|
||
|
afterEach(() => {
|
||
|
sinon.restore();
|
||
|
});
|
||
|
|
||
|
it('should render properly', () => {
|
||
4 years ago
|
const wrapper = shallow(<UserPreferencedCurrencyDisplay />);
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper).toHaveLength(1);
|
||
|
expect(wrapper.find(CurrencyDisplay)).toHaveLength(1);
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should pass all props to the CurrencyDisplay child component', () => {
|
||
6 years ago
|
const wrapper = shallow(
|
||
4 years ago
|
<UserPreferencedCurrencyDisplay prop1 prop2="test" prop3={1} />,
|
||
4 years ago
|
);
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper).toHaveLength(1);
|
||
|
expect(wrapper.find(CurrencyDisplay)).toHaveLength(1);
|
||
|
expect(wrapper.find(CurrencyDisplay).props().prop1).toStrictEqual(true);
|
||
|
expect(wrapper.find(CurrencyDisplay).props().prop2).toStrictEqual('test');
|
||
|
expect(wrapper.find(CurrencyDisplay).props().prop3).toStrictEqual(1);
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|