2021-02-04 19:15:23 +01:00
|
|
|
import assert from 'assert';
|
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display.component';
|
|
|
|
import CurrencyDisplay from '../../../ui/currency-display';
|
|
|
|
import * as currencyHook from '../../../../hooks/useCurrencyDisplay';
|
|
|
|
import * as currencyPrefHook from '../../../../hooks/useUserPreferencedCurrency';
|
2020-05-12 21:07:35 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('UserPreferencedCurrencyDisplay Component', function () {
|
|
|
|
describe('rendering', function () {
|
2020-05-12 21:07:35 +02:00
|
|
|
beforeEach(function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
sinon.stub(currencyHook, 'useCurrencyDisplay').returns(['1', {}]);
|
2020-11-03 00:41:28 +01:00
|
|
|
sinon
|
|
|
|
.stub(currencyPrefHook, 'useUserPreferencedCurrency')
|
2021-02-04 19:15:23 +01:00
|
|
|
.returns({ currency: 'ETH', decimals: 6 });
|
|
|
|
});
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render properly', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const wrapper = shallow(<UserPreferencedCurrencyDisplay />);
|
2018-10-17 01:03:29 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.ok(wrapper);
|
|
|
|
assert.strictEqual(wrapper.find(CurrencyDisplay).length, 1);
|
|
|
|
});
|
2018-10-17 01:03:29 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should pass all props to the CurrencyDisplay child component', function () {
|
2018-10-17 01:03:29 +02:00
|
|
|
const wrapper = shallow(
|
2020-11-03 00:41:28 +01:00
|
|
|
<UserPreferencedCurrencyDisplay prop1 prop2="test" prop3={1} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-10-17 01:03:29 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.ok(wrapper);
|
|
|
|
assert.strictEqual(wrapper.find(CurrencyDisplay).length, 1);
|
|
|
|
assert.strictEqual(wrapper.find(CurrencyDisplay).props().prop1, true);
|
|
|
|
assert.strictEqual(wrapper.find(CurrencyDisplay).props().prop2, 'test');
|
|
|
|
assert.strictEqual(wrapper.find(CurrencyDisplay).props().prop3, 1);
|
|
|
|
});
|
2020-05-12 21:07:35 +02:00
|
|
|
afterEach(function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
sinon.restore();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|