fix(app): terminal disconnect and resync (#14004)
This commit is contained in:
@@ -6,7 +6,10 @@ describe("terminalWriter", () => {
|
||||
const calls: string[] = []
|
||||
const scheduled: VoidFunction[] = []
|
||||
const writer = terminalWriter(
|
||||
(data) => calls.push(data),
|
||||
(data, done) => {
|
||||
calls.push(data)
|
||||
done?.()
|
||||
},
|
||||
(flush) => scheduled.push(flush),
|
||||
)
|
||||
|
||||
@@ -24,10 +27,38 @@ describe("terminalWriter", () => {
|
||||
test("flush is a no-op when empty", () => {
|
||||
const calls: string[] = []
|
||||
const writer = terminalWriter(
|
||||
(data) => calls.push(data),
|
||||
(data, done) => {
|
||||
calls.push(data)
|
||||
done?.()
|
||||
},
|
||||
(flush) => flush(),
|
||||
)
|
||||
writer.flush()
|
||||
expect(calls).toEqual([])
|
||||
})
|
||||
|
||||
test("flush waits for pending write completion", () => {
|
||||
const calls: string[] = []
|
||||
let done: VoidFunction | undefined
|
||||
const writer = terminalWriter(
|
||||
(data, finish) => {
|
||||
calls.push(data)
|
||||
done = finish
|
||||
},
|
||||
(flush) => flush(),
|
||||
)
|
||||
|
||||
writer.push("a")
|
||||
|
||||
let settled = false
|
||||
writer.flush(() => {
|
||||
settled = true
|
||||
})
|
||||
|
||||
expect(calls).toEqual(["a"])
|
||||
expect(settled).toBe(false)
|
||||
|
||||
done?.()
|
||||
expect(settled).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user