Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/jsx/src/hooks/useShortcuts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { describe, it, expect } from 'vitest';
import { registerShortcut, useShortcuts } from './useShortcuts.js';

describe('useShortcuts hook', () => {
it('returns empty array initially or already registered shortcuts', () => {
const initial = useShortcuts();
expect(Array.isArray(initial)).toBe(true);
});

it('registers new shortcut and returns updated list', () => {
const initialLength = useShortcuts().length;

const newShortcut = {
key: 'ctrl+k',
description: 'Clear console',
category: 'general',
};

registerShortcut(newShortcut);

const updated = useShortcuts();
expect(updated).toHaveLength(initialLength + 1);
expect(updated[updated.length - 1]).toEqual(newShortcut);
});
Comment thread
Harshithk951 marked this conversation as resolved.
});
Loading