1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
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

44 lines
1.1 KiB
JavaScript

import React from 'react'
import assert from 'assert'
import sinon from 'sinon'
import { shallow } from 'enzyme'
import Alert from '../index'
describe('Alert', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(
<Alert />
)
})
it('renders nothing with no visible boolean in state', () => {
const alert = wrapper.find('.global-alert')
assert.equal(alert.length, 0)
})
it('renders when visible in state is true, and message', () => {
const errorMessage = 'Error Message'
wrapper.setState({ visible: true, msg: errorMessage })
const alert = wrapper.find('.global-alert')
assert.equal(alert.length, 1)
const errorText = wrapper.find('.msg')
assert.equal(errorText.text(), errorMessage)
})
it('calls component method when componentWillReceiveProps is called', () => {
const animateInSpy = sinon.stub(wrapper.instance(), 'animateIn')
const animateOutSpy = sinon.stub(wrapper.instance(), 'animateOut')
wrapper.setProps({ visible: true })
assert(animateInSpy.calledOnce)
wrapper.setProps({ visible: false })
assert(animateOutSpy.calledOnce)
})
})