feat: release OpsXShell 2.1.0 native Tauri edition
This commit is contained in:
1 parent
e9a0d21758
commit
a3dba0c6ed
311 files changed
+31748
-14897
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { TerminalPipeline } from '../../src/utils/terminalPipeline'
|
||||
|
||||
describe('TerminalPipeline', () => {
|
||||
it('routes input and reports output bytes through one boundary', () => {
|
||||
const input = vi.fn()
|
||||
const write = vi.fn()
|
||||
const onOutputBytes = vi.fn()
|
||||
const scheduled: Array<() => void> = []
|
||||
const pipeline = new TerminalPipeline({
|
||||
input,
|
||||
output: {
|
||||
write,
|
||||
schedule: (callback) => {
|
||||
scheduled.push(callback)
|
||||
return scheduled.length
|
||||
},
|
||||
cancel: vi.fn(),
|
||||
},
|
||||
onOutputBytes,
|
||||
})
|
||||
|
||||
pipeline.input('date\r')
|
||||
pipeline.output(Uint8Array.from([0x68, 0x69]))
|
||||
scheduled.shift()?.()
|
||||
|
||||
expect(input).toHaveBeenCalledWith('date\r')
|
||||
expect(onOutputBytes).toHaveBeenCalledWith(2)
|
||||
expect(write).toHaveBeenCalledWith('hi')
|
||||
})
|
||||
|
||||
it('keeps split UTF-8 output intact and catches async input failures', async () => {
|
||||
const write = vi.fn()
|
||||
const onError = vi.fn()
|
||||
const scheduled: Array<() => void> = []
|
||||
const pipeline = new TerminalPipeline({
|
||||
input: () => Promise.reject(new Error('closed')),
|
||||
output: {
|
||||
write,
|
||||
schedule: (callback) => {
|
||||
scheduled.push(callback)
|
||||
return scheduled.length
|
||||
},
|
||||
cancel: vi.fn(),
|
||||
},
|
||||
onError,
|
||||
})
|
||||
|
||||
pipeline.input('x')
|
||||
pipeline.output(Uint8Array.from([0xe4, 0xb8]))
|
||||
pipeline.output(Uint8Array.from([0xad]))
|
||||
scheduled.shift()?.()
|
||||
await Promise.resolve()
|
||||
|
||||
expect(write).toHaveBeenCalledWith('中')
|
||||
expect(onError).toHaveBeenCalledOnce()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user