31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
isTerminalCopyShortcut,
|
|
isTerminalPasteShortcut,
|
|
isTerminalSplitShortcut,
|
|
} from '../../src/utils/terminalShortcuts'
|
|
|
|
function keyEvent(key: string, init: KeyboardEventInit = {}): KeyboardEvent {
|
|
return new KeyboardEvent('keydown', { key, ...init })
|
|
}
|
|
|
|
describe('terminal shortcuts', () => {
|
|
it('uses Cmd+C and Cmd+V on macOS', () => {
|
|
expect(isTerminalCopyShortcut(keyEvent('c', { metaKey: true }))).toBe(true)
|
|
expect(isTerminalPasteShortcut(keyEvent('v', { metaKey: true }))).toBe(true)
|
|
})
|
|
|
|
it('uses Ctrl+Shift+C and Ctrl+Shift+V outside macOS', () => {
|
|
expect(isTerminalCopyShortcut(keyEvent('C', { ctrlKey: true, shiftKey: true }))).toBe(true)
|
|
expect(isTerminalPasteShortcut(keyEvent('V', { ctrlKey: true, shiftKey: true }))).toBe(true)
|
|
})
|
|
|
|
it('uses Cmd+D for splitting', () => {
|
|
expect(isTerminalSplitShortcut(keyEvent('d', { metaKey: true }))).toBe(true)
|
|
})
|
|
|
|
it('does not consume Ctrl+D, which must reach the remote shell as EOF', () => {
|
|
expect(isTerminalSplitShortcut(keyEvent('d', { ctrlKey: true }))).toBe(false)
|
|
})
|
|
})
|