mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-27 23:06:54 +05:00
feat(ipuaro): add TUI components and hooks (v0.11.0)
This commit is contained in:
67
packages/ipuaro/tests/unit/tui/hooks/useHotkeys.test.ts
Normal file
67
packages/ipuaro/tests/unit/tui/hooks/useHotkeys.test.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Tests for useHotkeys hook.
|
||||
*/
|
||||
|
||||
import { describe, expect, it, vi, beforeEach } from "vitest"
|
||||
|
||||
describe("useHotkeys", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
describe("module exports", () => {
|
||||
it("should export useHotkeys function", async () => {
|
||||
const mod = await import("../../../../src/tui/hooks/useHotkeys.js")
|
||||
expect(mod.useHotkeys).toBeDefined()
|
||||
expect(typeof mod.useHotkeys).toBe("function")
|
||||
})
|
||||
})
|
||||
|
||||
describe("HotkeyHandlers interface", () => {
|
||||
it("should accept onInterrupt callback", () => {
|
||||
const handlers = {
|
||||
onInterrupt: vi.fn(),
|
||||
}
|
||||
expect(handlers.onInterrupt).toBeDefined()
|
||||
})
|
||||
|
||||
it("should accept onExit callback", () => {
|
||||
const handlers = {
|
||||
onExit: vi.fn(),
|
||||
}
|
||||
expect(handlers.onExit).toBeDefined()
|
||||
})
|
||||
|
||||
it("should accept onUndo callback", () => {
|
||||
const handlers = {
|
||||
onUndo: vi.fn(),
|
||||
}
|
||||
expect(handlers.onUndo).toBeDefined()
|
||||
})
|
||||
|
||||
it("should accept all callbacks together", () => {
|
||||
const handlers = {
|
||||
onInterrupt: vi.fn(),
|
||||
onExit: vi.fn(),
|
||||
onUndo: vi.fn(),
|
||||
}
|
||||
expect(handlers.onInterrupt).toBeDefined()
|
||||
expect(handlers.onExit).toBeDefined()
|
||||
expect(handlers.onUndo).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("UseHotkeysOptions interface", () => {
|
||||
it("should accept enabled option", () => {
|
||||
const options = {
|
||||
enabled: true,
|
||||
}
|
||||
expect(options.enabled).toBe(true)
|
||||
})
|
||||
|
||||
it("should default enabled to undefined when not provided", () => {
|
||||
const options = {}
|
||||
expect((options as { enabled?: boolean }).enabled).toBeUndefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user