1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-25 12:52:33 +02:00
metamask-extension/ui/app/pages/settings/settings-tab/tests/settings-tab.test.js
Thomas Huang 5d1c9313db
Various component tests and some conditional statements (#7765)
* Various component tests and some conditional statements

Conditional in account-menu in removeAccount when keyring sometimes is not initially provideed
Conditional on unlock-page when there is no target.getBoundingClientRect on the element.

* Update helpers

* Remove component debugging

* Add default params for render helpers

* Remove stubComponent for old Mascot
Changes in https://github.com/MetaMask/metamask-extension/pull/7893 has prevented the need to stub it out.

Change logout to lock in account-menu test
2020-01-30 11:34:45 -08:00

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