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.
143 lines
4.2 KiB
143 lines
4.2 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';
|
||
3 years ago
|
import 'jest-canvas-mock';
|
||
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,
|
||
3 years ago
|
selectedAddress: '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1',
|
||
|
tokenList: {
|
||
|
'0x6b175474e89094c44da98b954eedeac495271d0f': {
|
||
|
address: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
||
|
symbol: 'META',
|
||
|
decimals: 18,
|
||
|
image: 'metamark.svg',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
'0xB8c77482e45F1F44dE1745F52C74426C631bDD52': {
|
||
|
address: '0xB8c77482e45F1F44dE1745F52C74426C631bDD52',
|
||
|
symbol: '0X',
|
||
|
decimals: 18,
|
||
|
image: '0x.svg',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
'0x1f9840a85d5af5bf1d1762f925bdaddc4201f984': {
|
||
|
address: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',
|
||
|
symbol: 'AST',
|
||
|
decimals: 18,
|
||
|
image: 'ast.png',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
'0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2': {
|
||
|
address: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
|
||
|
symbol: 'BAT',
|
||
|
decimals: 18,
|
||
|
image: 'BAT_icon.svg',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
'0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1': {
|
||
|
address: '0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1',
|
||
|
symbol: 'CVL',
|
||
|
decimals: 18,
|
||
|
image: 'CVL_token.svg',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e': {
|
||
|
address: '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e',
|
||
|
symbol: 'GLA',
|
||
|
decimals: 18,
|
||
|
image: 'gladius.svg',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
'0x467Bccd9d29f223BcE8043b84E8C8B282827790F': {
|
||
|
address: '0x467Bccd9d29f223BcE8043b84E8C8B282827790F',
|
||
|
symbol: 'GNO',
|
||
|
decimals: 18,
|
||
|
image: 'gnosis.svg',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
'0xff20817765cb7f73d4bde2e66e067e58d11095c2': {
|
||
|
address: '0xff20817765cb7f73d4bde2e66e067e58d11095c2',
|
||
|
symbol: 'OMG',
|
||
|
decimals: 18,
|
||
|
image: 'omg.jpg',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
'0x8e870d67f660d95d5be530380d0ec0bd388289e1': {
|
||
|
address: '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
|
||
|
symbol: 'WED',
|
||
|
decimals: 18,
|
||
|
image: 'wed.png',
|
||
|
unlisted: false,
|
||
|
},
|
||
|
},
|
||
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
|
|
||
3 years ago
|
it('clicks jazzicon', () => {
|
||
|
const toggleBlockies = wrapper.find('#jazzicon');
|
||
5 years ago
|
|
||
4 years ago
|
toggleBlockies.simulate('click');
|
||
4 years ago
|
expect(props.setUseBlockie.calledOnce).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
3 years ago
|
it('clicks blockies icon', () => {
|
||
|
const toggleBlockies = wrapper.find('#blockies');
|
||
|
|
||
|
toggleBlockies.simulate('click');
|
||
|
expect(props.setUseBlockie.calledOnce).toStrictEqual(false);
|
||
|
});
|
||
|
|
||
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
|
});
|