Created
February 4, 2019 12:28
-
-
Save egorvinogradov/8cb5ae57bfbeeb17f88c5abce9b576bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it("Menu scrolls if the hovered option is out of the viewport", () => { | |
const extraOptions = [ | |
{ label: "value D4", value: "D4" }, | |
{ label: "value E5", value: "E5" }, | |
{ label: "value F6", value: "F6" }, | |
]; | |
const updatedOptions = options.concat(extraOptions); | |
console.log('--- extra', updatedOptions); | |
const wrapper = mount(<Menu options={updatedOptions} onChange={onChange}/>, { | |
attachTo: div | |
}); | |
const items = wrapper.find(".bg-menu__item"); | |
const menu = wrapper.getDOMNode(); | |
expect(wrapper.state().hoveredIdx).toBe(0); | |
expect(items.length).toBe(6); | |
items.at(4).simulate('mouseEnter'); | |
expect(wrapper.state().hoveredIdx).toBe(4); | |
simulant.fire(menu, "keydown", { keyCode: 40 }); // Down arrow | |
expect(wrapper.state().hoveredIdx).toBe(5); | |
console.log('--- menu.scrollTop 2', menu.scrollTop); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment