mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-10-23 03:36:18 +02:00
76a2a9bb8b
* @metamask/eslint-config@5.0.0 * Update eslintrc and prettierrc * yarn lint:fix
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
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';
|
|
|
|
describe('UserPreferencedCurrencyDisplay Component', function () {
|
|
describe('rendering', function () {
|
|
beforeEach(function () {
|
|
sinon.stub(currencyHook, 'useCurrencyDisplay').returns(['1', {}]);
|
|
sinon
|
|
.stub(currencyPrefHook, 'useUserPreferencedCurrency')
|
|
.returns({ currency: 'ETH', decimals: 6 });
|
|
});
|
|
it('should render properly', function () {
|
|
const wrapper = shallow(<UserPreferencedCurrencyDisplay />);
|
|
|
|
assert.ok(wrapper);
|
|
assert.strictEqual(wrapper.find(CurrencyDisplay).length, 1);
|
|
});
|
|
|
|
it('should pass all props to the CurrencyDisplay child component', function () {
|
|
const wrapper = shallow(
|
|
<UserPreferencedCurrencyDisplay prop1 prop2="test" prop3={1} />,
|
|
);
|
|
|
|
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);
|
|
});
|
|
afterEach(function () {
|
|
sinon.restore();
|
|
});
|
|
});
|
|
});
|