|
|
|
@ -12,7 +12,6 @@ const mockState = { |
|
|
|
|
|
|
|
|
|
describe('Dropdown components', function () { |
|
|
|
|
let onClickOutside |
|
|
|
|
let closeMenu |
|
|
|
|
let onClick |
|
|
|
|
|
|
|
|
|
const dropdownComponentProps = { |
|
|
|
@ -32,7 +31,6 @@ describe('Dropdown components', function () { |
|
|
|
|
let component |
|
|
|
|
beforeEach(function () { |
|
|
|
|
onClickOutside = sinon.spy() |
|
|
|
|
closeMenu = sinon.spy() |
|
|
|
|
onClick = sinon.spy() |
|
|
|
|
|
|
|
|
|
store = createMockStore(mockState) |
|
|
|
@ -46,8 +44,8 @@ describe('Dropdown components', function () { |
|
|
|
|
` |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|
<li closeMenu={closeMenu} onClick={onClick}>Item 1</li> |
|
|
|
|
<li closeMenu={closeMenu} onClick={onClick}>Item 2</li> |
|
|
|
|
<li onClick={onClick}>Item 1</li> |
|
|
|
|
<li onClick={onClick}>Item 2</li> |
|
|
|
|
</Dropdown> |
|
|
|
|
), store) |
|
|
|
|
dropdownComponent = component |
|
|
|
@ -58,17 +56,10 @@ describe('Dropdown components', function () { |
|
|
|
|
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 () { |
|
|
|
|
const items = dropdownComponent.find('li') |
|
|
|
|
const node = items.at(0) |
|
|
|
|
node.simulate('click') |
|
|
|
|
assert.equal(onClick.calledOnce, true) |
|
|
|
|
assert.ok(onClick.calledOnce) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|