Skip to content

Commit

Permalink
test(react-keytips): add test for useTree
Browse files Browse the repository at this point in the history
  • Loading branch information
mainframev committed Aug 26, 2024
1 parent cdf54c8 commit cf0ef38
Show file tree
Hide file tree
Showing 2 changed files with 495 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/react-keytips/src/hooks/useHotkeys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useHotkeys } from './useHotkeys';
import userEvent from '@testing-library/user-event';

describe('useHotkeys', () => {
it('should trigger callbacks', () => {
it('should trigger callbacks', async () => {
const handlerFirst = jest.fn();
const handlerSecond = jest.fn();

Expand All @@ -14,17 +14,17 @@ describe('useHotkeys', () => {
])
);

userEvent.keyboard('{Alt}{Control}');
await userEvent.keyboard('{Alt>}{Control}');
expect(handlerFirst).toHaveBeenCalledTimes(1);

userEvent.keyboard('{Alt}{x}');
await userEvent.keyboard('{Alt>}{x}');
expect(handlerSecond).toHaveBeenCalledTimes(1);
});

it('should not trigger callback', () => {
it('should not trigger callback', async () => {
const cb = jest.fn();
renderHook(() => useHotkeys([['alt+X', cb]]));
userEvent.keyboard('{Alt}{C}');
await userEvent.keyboard('{Alt}{C}');
expect(cb).toHaveBeenCalledTimes(0);
});
});
Loading

0 comments on commit cf0ef38

Please sign in to comment.