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

46 lines
1.1 KiB
JavaScript
Raw Normal View History

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'
2017-11-02 18:28:41 +01:00
2017-07-13 09:40:22 +02:00
describe('Dropdown components', function () {
const mockState = {
metamask: {},
}
const props = {
2017-11-02 18:28:41 +01:00
isOpen: true,
zIndex: 11,
onClickOutside: sinon.spy(),
2017-11-02 18:28:41 +01:00
style: {
position: 'absolute',
right: 0,
top: '36px',
},
innerStyle: {},
}
it('invokes click handler when item clicked', function () {
const store = configureMockStore()(mockState)
2017-07-13 09:40:22 +02:00
const onClickSpy = sinon.spy()
2017-07-13 09:40:22 +02:00
const { getByText } = renderWithProvider(
<Dropdown {...props}>
<li onClick={onClickSpy}>Item 1</li>
<li onClick={onClickSpy}>Item 2</li>
</Dropdown>, store,
)
2017-07-18 14:23:25 +02:00
const item1 = getByText(/Item 1/u)
fireEvent.click(item1)
assert.ok(onClickSpy.calledOnce)
2018-07-03 00:49:33 +02:00
})
2018-07-03 00:49:33 +02:00
})