2020-01-30 20:34:45 +01:00
|
|
|
import assert from 'assert'
|
2020-08-18 21:18:25 +02:00
|
|
|
import React from 'react'
|
2020-01-30 20:34:45 +01:00
|
|
|
import sinon from 'sinon'
|
|
|
|
import { mount } from 'enzyme'
|
2020-08-19 18:27:05 +02:00
|
|
|
import SettingsTab from '..'
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Settings Tab', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
let wrapper
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
setCurrentCurrency: sinon.spy(),
|
|
|
|
displayWarning: sinon.spy(),
|
|
|
|
setUseBlockie: sinon.spy(),
|
|
|
|
updateCurrentLocale: sinon.spy(),
|
|
|
|
setUseNativeCurrencyAsPrimaryCurrencyPreference: sinon.spy(),
|
|
|
|
warning: '',
|
|
|
|
currentLocale: 'en',
|
|
|
|
useBlockie: false,
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
conversionDate: 1,
|
|
|
|
nativeCurrency: 'eth',
|
|
|
|
useNativeCurrencyAsPrimaryCurrency: true,
|
|
|
|
}
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
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
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
2020-01-30 20:34:45 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('selects currency', async function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const selectCurrency = wrapper.find({ placeholder: 'selectCurrency' })
|
|
|
|
|
|
|
|
selectCurrency.props().onSelect('eur')
|
|
|
|
assert(props.setCurrentCurrency.calledOnce)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('selects locale', async function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const selectLocale = wrapper.find({ placeholder: 'selectLocale' })
|
|
|
|
|
|
|
|
await selectLocale.props().onSelect('ja')
|
|
|
|
assert(props.updateCurrentLocale.calledOnce)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('sets fiat primary currency', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const selectFiat = wrapper.find('#fiat-primary-currency')
|
|
|
|
|
|
|
|
selectFiat.simulate('change')
|
|
|
|
assert(props.setUseNativeCurrencyAsPrimaryCurrencyPreference.calledOnce)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('toggles blockies', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const toggleBlockies = wrapper.find({ type: 'checkbox' })
|
|
|
|
|
|
|
|
toggleBlockies.simulate('click')
|
|
|
|
assert(props.setUseBlockie.calledOnce)
|
|
|
|
})
|
|
|
|
})
|