Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test("should move focus the last focusable element when the end key is pressed", (): void => {
const rendered: any = mount(
{itemA}
{itemB}
{itemC}
<div>four</div>
,
{ attachTo: container }
);
expect(rendered.state("focusIndex")).toBe(0);
rendered.childAt(0).simulate("keydown", { keyCode: KeyCodes.end });
expect(rendered.state("focusIndex")).toBe(2);
rendered.detach();
});
test("should select a range and move focus to the end when ctrl-shift-end is pressed in multi-select mode", (): void => {
const rendered: any = mount(
{itemA}
{itemB}
{itemC}
,
{ attachTo: container }
);
rendered.childAt(0).simulate("keydown", { keyCode: KeyCodes.arrowDown });
expect(rendered.state("focusIndex")).toBe(1);
expect(rendered.state("selectedItems").length).toBe(0);
rendered.childAt(0).simulate("keydown", {
keyCode: KeyCodes.end,
shiftKey: true,
ctrlKey: true,
});
expect(rendered.state("focusIndex")).toBe(2);
expect(rendered.state("selectedItems").length).toBe(2);
expect(rendered.state("selectedItems")[0].id).toBe("b");
expect(rendered.state("selectedItems")[1].id).toBe("c");
rendered.detach();
});
test("should move focus the last focusable element when the end key is pressed", (): void => {
const rendered: any = mount(
<div role="menuitem">one</div>
<div role="menuitem">two</div>
<div role="menuitem">three</div>
<div>four</div>
);
rendered.childAt(0).simulate("keydown", { keyCode: KeyCodes.end });
expect(rendered.state("focusIndex")).toBe(2);
});
.prop("active")
).toBe(true);
expect(
rendered
.find(Tab.displayName)
.at(1)
.prop("active")
).toBe(false);
expect(
rendered
.find(Tab.displayName)
.at(2)
.prop("active")
).toBe(false);
tab1.simulate("keydown", { keyCode: KeyCodes.end });
expect(
rendered
.find(Tab.displayName)
.at(0)
.prop("tabIndex")
).toEqual(-1);
expect(
rendered
.find(Tab.displayName)
.at(1)
.prop("tabIndex")
).toEqual(-1);
expect(
rendered
.find(Tab.displayName)
.prop("active")
).toBe(true);
expect(
rendered
.find(Tab.displayName)
.at(1)
.prop("active")
).toBe(false);
expect(
rendered
.find(Tab.displayName)
.at(2)
.prop("active")
).toBe(false);
tab1.simulate("keydown", { keyCode: KeyCodes.end });
expect(onUpdate).toBeCalledWith(id2);
expect(
rendered
.find(Tab.displayName)
.at(0)
.prop("tabIndex")
).toEqual(0);
expect(
rendered
.find(Tab.displayName)
.at(1)
.prop("tabIndex")
).toEqual(-1);
expect(
case KeyCodes.arrowDown:
this.focusNextTreeItem(dataLocation);
break;
case KeyCodes.arrowUp:
this.focusPreviousTreeItem(dataLocation);
break;
case KeyCodes.arrowRight:
this.focusAndOpenTreeItems(dataLocation);
break;
case KeyCodes.arrowLeft:
this.focusAndCloseTreeItems(dataLocation);
break;
case KeyCodes.home:
this.focusFirstTreeItem();
break;
case KeyCodes.end:
this.focusLastTreeItem();
break;
default:
break;
}
}
};
};