Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('keyboardNavigation: true - arrow keys move between steps', async() => {
const tour = new Tour();
const step = new Step(tour, {});
const tourBackStub = stub(tour, 'back');
const tourNextStub = stub(tour, 'next');
expect(tourBackStub.called).toBe(false);
expect(tourNextStub.called).toBe(false);
const { container } = render(ShepherdElement, {
props: {
step
}
});
fireEvent.keyDown(container.querySelector('.shepherd-element'), { keyCode: 39 });
expect(tourNextStub.called).toBe(true);
fireEvent.keyDown(container.querySelector('.shepherd-element'), { keyCode: 37 });
expect(tourBackStub.called).toBe(true);
tourBackStub.restore();
tourNextStub.restore();
});
pressKey: async (key) => {
const el = await elem();
const def = getDefinitionForKeyType(key);
await fireEvent.keyDown(el, def);
await fireEvent.keyUp(el, def);
},
hasClass: async (className: string) => (await elem()).classList.contains(className),