mirror of
https://github.com/stablyai/orca.git
synced 2026-11-14 09:57:48 +00:00
21 lines
751 B
TypeScript
21 lines
751 B
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { openWindowsConsoleInput, WINDOWS_CONSOLE_INPUT_DEVICE } from './windows-console-input'
|
|
|
|
describe('openWindowsConsoleInput', () => {
|
|
it('opens CONIN$ read-write and disposes the fd once', () => {
|
|
const openSync = vi.fn(() => 11)
|
|
const closeSync = vi.fn()
|
|
const opened = openWindowsConsoleInput({ platform: 'win32', openSync, closeSync })
|
|
expect(opened).not.toBe('inherit')
|
|
if (opened === 'inherit') {
|
|
return
|
|
}
|
|
expect(openSync).toHaveBeenCalledWith(WINDOWS_CONSOLE_INPUT_DEVICE, 'r+')
|
|
expect(opened.fd).toBe(11)
|
|
opened.dispose()
|
|
opened.dispose()
|
|
expect(closeSync).toHaveBeenCalledOnce()
|
|
expect(closeSync).toHaveBeenCalledWith(11)
|
|
})
|
|
})
|