Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { withTimeout } from './with-timeout'
|
||||
|
||||
describe('withTimeout', () => {
|
||||
it('rejects with an onTimeout exception instead of letting it escape the timer callback', async () => {
|
||||
vi.useFakeTimers()
|
||||
|
||||
try {
|
||||
const callbackFailure = new Error('abort callback failed')
|
||||
|
||||
const result = withTimeout(new Promise<never>(() => undefined), 10, 'work timed out', () => {
|
||||
throw callbackFailure
|
||||
})
|
||||
|
||||
const rejection = expect(result).rejects.toBe(callbackFailure)
|
||||
|
||||
await vi.advanceTimersByTimeAsync(10)
|
||||
await rejection
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user