How to use the @testing-library/svelte.fireEvent.keyDown function in @testing-library/svelte

To help you get started, we’ve selected a few @testing-library/svelte examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shipshapecode / shepherd / test / unit / components / shepherd-element.spec.js View on Github external
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();
    });
github wix-incubator / unidriver / adapters / jsdom-svelte / src / index.ts View on Github external
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),