mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix propTypes and test props for Dropdown components (#7851)
This commit is contained in:
parent
78044a5cdc
commit
b4ca671b6b
@ -12,7 +12,6 @@ const mockState = {
|
|||||||
|
|
||||||
describe('Dropdown components', function () {
|
describe('Dropdown components', function () {
|
||||||
let onClickOutside
|
let onClickOutside
|
||||||
let closeMenu
|
|
||||||
let onClick
|
let onClick
|
||||||
|
|
||||||
const dropdownComponentProps = {
|
const dropdownComponentProps = {
|
||||||
@ -32,7 +31,6 @@ describe('Dropdown components', function () {
|
|||||||
let component
|
let component
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
onClickOutside = sinon.spy()
|
onClickOutside = sinon.spy()
|
||||||
closeMenu = sinon.spy()
|
|
||||||
onClick = sinon.spy()
|
onClick = sinon.spy()
|
||||||
|
|
||||||
store = createMockStore(mockState)
|
store = createMockStore(mockState)
|
||||||
@ -46,8 +44,8 @@ describe('Dropdown components', function () {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<li closeMenu={closeMenu} onClick={onClick}>Item 1</li>
|
<li onClick={onClick}>Item 1</li>
|
||||||
<li closeMenu={closeMenu} onClick={onClick}>Item 2</li>
|
<li onClick={onClick}>Item 2</li>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
), store)
|
), store)
|
||||||
dropdownComponent = component
|
dropdownComponent = component
|
||||||
@ -58,17 +56,10 @@ describe('Dropdown components', function () {
|
|||||||
assert.equal(items.length, 2)
|
assert.equal(items.length, 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('closes when item clicked', function () {
|
|
||||||
const items = dropdownComponent.find('li')
|
|
||||||
const node = items.at(0)
|
|
||||||
node.simulate('click')
|
|
||||||
assert.equal(node.props().closeMenu, closeMenu)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('invokes click handler when item clicked', function () {
|
it('invokes click handler when item clicked', function () {
|
||||||
const items = dropdownComponent.find('li')
|
const items = dropdownComponent.find('li')
|
||||||
const node = items.at(0)
|
const node = items.at(0)
|
||||||
node.simulate('click')
|
node.simulate('click')
|
||||||
assert.equal(onClick.calledOnce, true)
|
assert.ok(onClick.calledOnce)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -8,7 +8,7 @@ export default class MenuDroppoComponent extends Component {
|
|||||||
isOpen: PropTypes.bool.isRequired,
|
isOpen: PropTypes.bool.isRequired,
|
||||||
innerStyle: PropTypes.object,
|
innerStyle: PropTypes.object,
|
||||||
children: PropTypes.node.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
onClickOutside: PropTypes.func.isRequired,
|
onClickOutside: PropTypes.func,
|
||||||
containerClassName: PropTypes.string,
|
containerClassName: PropTypes.string,
|
||||||
zIndex: PropTypes.number,
|
zIndex: PropTypes.number,
|
||||||
style: PropTypes.object.isRequired,
|
style: PropTypes.object.isRequired,
|
||||||
|
Loading…
Reference in New Issue
Block a user