1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 11:46:13 +02:00
metamask-extension/ui/app/pages/settings/settings-tab/tests/settings-tab.test.js
Whymarrh Whitby 4f0a205369
Use eslint@6.8.0 (#8978)
* Use eslint@6.8.0
* yarn lint:fix
2020-07-14 12:50:41 -02:30

62 lines
1.6 KiB
JavaScript

import React from 'react'
import assert from 'assert'
import sinon from 'sinon'
import { mount } from 'enzyme'
import SettingsTab from '../index'
describe('Settings Tab', function () {
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,
}
beforeEach(function () {
wrapper = mount(
<SettingsTab.WrappedComponent {...props} />, {
context: {
t: (str) => str,
},
},
)
})
it('selects currency', async function () {
const selectCurrency = wrapper.find({ placeholder: 'selectCurrency' })
selectCurrency.props().onSelect('eur')
assert(props.setCurrentCurrency.calledOnce)
})
it('selects locale', async function () {
const selectLocale = wrapper.find({ placeholder: 'selectLocale' })
await selectLocale.props().onSelect('ja')
assert(props.updateCurrentLocale.calledOnce)
})
it('sets fiat primary currency', function () {
const selectFiat = wrapper.find('#fiat-primary-currency')
selectFiat.simulate('change')
assert(props.setUseNativeCurrencyAsPrimaryCurrencyPreference.calledOnce)
})
it('toggles blockies', function () {
const toggleBlockies = wrapper.find({ type: 'checkbox' })
toggleBlockies.simulate('click')
assert(props.setUseBlockie.calledOnce)
})
})