1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 15:50:28 +01:00
metamask-extension/test/unit/responsive/components/dropdown-test.js
Thomas Huang 9e6ba089d9
Remove mountWithStore enzyme component wrapper (#9309)
* Remove mountWithStore enzyme component wrapper in favor for renderWithProvider testing-library/react for tests

Change dropdown component tests to testing-library/react
2020-08-26 15:55:24 -07:00

46 lines
1.1 KiB
JavaScript

import assert from 'assert'
import React from 'react'
import configureMockStore from 'redux-mock-store'
import { fireEvent } from '@testing-library/react'
import sinon from 'sinon'
import { renderWithProvider } from '../../../lib/render-helpers'
import { Dropdown } from '../../../../ui/app/components/app/dropdowns/components/dropdown'
describe('Dropdown components', function () {
const mockState = {
metamask: {},
}
const props = {
isOpen: true,
zIndex: 11,
onClickOutside: sinon.spy(),
style: {
position: 'absolute',
right: 0,
top: '36px',
},
innerStyle: {},
}
it('invokes click handler when item clicked', function () {
const store = configureMockStore()(mockState)
const onClickSpy = sinon.spy()
const { getByText } = renderWithProvider(
<Dropdown {...props}>
<li onClick={onClickSpy}>Item 1</li>
<li onClick={onClickSpy}>Item 2</li>
</Dropdown>, store,
)
const item1 = getByText(/Item 1/u)
fireEvent.click(item1)
assert.ok(onClickSpy.calledOnce)
})
})