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.
69 lines
1.9 KiB
69 lines
1.9 KiB
4 years ago
|
import React from 'react';
|
||
|
import sinon from 'sinon';
|
||
|
import { mount } from 'enzyme';
|
||
4 years ago
|
import SettingsTab from './settings-tab.container';
|
||
5 years ago
|
|
||
4 years ago
|
describe('Settings Tab', () => {
|
||
4 years ago
|
let wrapper;
|
||
5 years ago
|
|
||
|
const props = {
|
||
|
setCurrentCurrency: sinon.spy(),
|
||
|
displayWarning: sinon.spy(),
|
||
|
setUseBlockie: sinon.spy(),
|
||
|
updateCurrentLocale: sinon.spy(),
|
||
|
setUseNativeCurrencyAsPrimaryCurrencyPreference: sinon.spy(),
|
||
4 years ago
|
setHideZeroBalanceTokens: sinon.spy(),
|
||
5 years ago
|
warning: '',
|
||
|
currentLocale: 'en',
|
||
|
useBlockie: false,
|
||
|
currentCurrency: 'usd',
|
||
|
conversionDate: 1,
|
||
|
nativeCurrency: 'eth',
|
||
|
useNativeCurrencyAsPrimaryCurrency: true,
|
||
4 years ago
|
};
|
||
4 years ago
|
beforeEach(() => {
|
||
4 years ago
|
wrapper = mount(<SettingsTab.WrappedComponent {...props} />, {
|
||
|
context: {
|
||
|
t: (str) => str,
|
||
4 years ago
|
},
|
||
4 years ago
|
});
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('selects currency', async () => {
|
||
4 years ago
|
const selectCurrency = wrapper.find('#select-currency');
|
||
5 years ago
|
|
||
4 years ago
|
selectCurrency.props().onChange('eur');
|
||
4 years ago
|
expect(props.setCurrentCurrency.calledOnce).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('selects locale', async () => {
|
||
4 years ago
|
const selectLocale = wrapper.find('#select-locale');
|
||
5 years ago
|
|
||
4 years ago
|
await selectLocale.props().onChange('ja');
|
||
4 years ago
|
expect(props.updateCurrentLocale.calledOnce).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('sets fiat primary currency', () => {
|
||
4 years ago
|
const selectFiat = wrapper.find('#fiat-primary-currency');
|
||
5 years ago
|
|
||
4 years ago
|
selectFiat.simulate('change');
|
||
4 years ago
|
expect(
|
||
|
props.setUseNativeCurrencyAsPrimaryCurrencyPreference.calledOnce,
|
||
|
).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('toggles blockies', () => {
|
||
4 years ago
|
const toggleBlockies = wrapper.find('#blockie-optin input');
|
||
5 years ago
|
|
||
4 years ago
|
toggleBlockies.simulate('click');
|
||
4 years ago
|
expect(props.setUseBlockie.calledOnce).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('toggles hiding zero balance', () => {
|
||
4 years ago
|
const toggleBlockies = wrapper.find('#toggle-zero-balance input');
|
||
|
|
||
|
toggleBlockies.simulate('click');
|
||
4 years ago
|
expect(props.setHideZeroBalanceTokens.calledOnce).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
4 years ago
|
});
|