Skip to content

Commit 51738fe

Browse files
committed
test(sim-cli): use the shared sleep and test hooks in the terminal tests
1 parent d00c29e commit 51738fe

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎packages/sim-cli/src/terminal/interrupts.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ function interruptedWithBackedUpPipe(): Promise<{ bytes: number; signal: string
1414
const script = `
1515
const { deferInterrupts } = await import(${JSON.stringify(interrupts)})
1616
const { writeStdout } = await import(${JSON.stringify(io)})
17+
const { sleep } = await import('@sim/utils/helpers')
1718
await deferInterrupts(async () => {
1819
process.stderr.write('ready\\n')
19-
await new Promise((resolve) => setTimeout(resolve, 300))
20+
await sleep(300)
2021
writeStdout('x'.repeat(${OUTPUT_BYTES}))
2122
}, { waiting: 'waiting', abandoned: 'abandoned' })
2223
`
23-
const child = spawn('bun', ['-e', script], { stdio: ['ignore', 'pipe', 'pipe'] })
24+
const child = spawn('bun', ['-e', script], {
25+
cwd: join(import.meta.dirname, '../..'),
26+
stdio: ['ignore', 'pipe', 'pipe'],
27+
})
2428
let bytes = 0
2529
child.stdout.pause()
2630
child.stdout.on('data', (chunk: Buffer) => {

‎packages/sim-cli/src/terminal/line-input.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ beforeEach(() => {
2020

2121
afterEach(() => {
2222
Object.defineProperty(process.stderr, 'isTTY', { value: undefined, configurable: true })
23-
vi.restoreAllMocks()
2423
})
2524

2625
describe('askLine', () => {

0 commit comments

Comments
 (0)