fix(tui): restore clipboard hotkeys in clarify mode

This commit is contained in:
kshitijk4poor 2026-04-19 12:12:26 +05:30 committed by kshitij
parent 8c9fdedaf5
commit c3af012a35
4 changed files with 109 additions and 4 deletions

View file

@ -0,0 +1,29 @@
import { describe, expect, it, vi } from 'vitest'
import { readClipboardText } from '../lib/clipboard.js'
describe('readClipboardText', () => {
it('does nothing off macOS', () => {
const run = vi.fn()
expect(readClipboardText('linux', run)).toBeNull()
expect(run).not.toHaveBeenCalled()
})
it('reads text from pbpaste on macOS', () => {
const run = vi.fn().mockReturnValue({ status: 0, stdout: 'hello world\n' })
expect(readClipboardText('darwin', run)).toBe('hello world\n')
expect(run).toHaveBeenCalledWith(
'pbpaste',
[],
expect.objectContaining({ encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })
)
})
it('returns null when pbpaste fails', () => {
const run = vi.fn().mockReturnValue({ status: 1, stdout: '' })
expect(readClipboardText('darwin', run)).toBeNull()
})
})