2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import { mount } from 'enzyme';
|
2021-03-16 22:00:08 +01:00
|
|
|
import SettingsTab from './settings-tab.container';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Settings Tab', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const props = {
|
|
|
|
setCurrentCurrency: sinon.spy(),
|
|
|
|
displayWarning: sinon.spy(),
|
|
|
|
setUseBlockie: sinon.spy(),
|
|
|
|
updateCurrentLocale: sinon.spy(),
|
|
|
|
setUseNativeCurrencyAsPrimaryCurrencyPreference: sinon.spy(),
|
2021-03-09 20:35:55 +01:00
|
|
|
setHideZeroBalanceTokens: sinon.spy(),
|
2020-01-30 20:34:45 +01:00
|
|
|
warning: '',
|
|
|
|
currentLocale: 'en',
|
|
|
|
useBlockie: false,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
conversionDate: 1,
|
|
|
|
nativeCurrency: 'eth',
|
|
|
|
useNativeCurrencyAsPrimaryCurrency: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper = mount(<SettingsTab.WrappedComponent {...props} />, {
|
|
|
|
context: {
|
|
|
|
t: (str) => str,
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('selects currency', async () => {
|
2021-02-19 20:03:44 +01:00
|
|
|
const selectCurrency = wrapper.find('#select-currency');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-02-19 20:03:44 +01:00
|
|
|
selectCurrency.props().onChange('eur');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.setCurrentCurrency.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('selects locale', async () => {
|
2021-02-19 20:03:44 +01:00
|
|
|
const selectLocale = wrapper.find('#select-locale');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-02-19 20:03:44 +01:00
|
|
|
await selectLocale.props().onChange('ja');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.updateCurrentLocale.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('sets fiat primary currency', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const selectFiat = wrapper.find('#fiat-primary-currency');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
selectFiat.simulate('change');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
|
|
|
props.setUseNativeCurrencyAsPrimaryCurrencyPreference.calledOnce,
|
|
|
|
).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('toggles blockies', () => {
|
2021-03-09 20:35:55 +01:00
|
|
|
const toggleBlockies = wrapper.find('#blockie-optin input');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
toggleBlockies.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.setUseBlockie.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2021-03-09 20:35:55 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('toggles hiding zero balance', () => {
|
2021-03-09 20:35:55 +01:00
|
|
|
const toggleBlockies = wrapper.find('#toggle-zero-balance input');
|
|
|
|
|
|
|
|
toggleBlockies.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.setHideZeroBalanceTokens.calledOnce).toStrictEqual(true);
|
2021-03-09 20:35:55 +01:00
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|