Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

893 B
Raw Blame
import { afterEach, describe, expect, it, vi } from 'vitest'
import { startDiagnosticFetchTimeout } from './diagnostic-fetch-timeout'

describe('diagnostic fetch timeout', () => {
  afterEach(() => {
    vi.useRealTimers()
  })

  it('aborts when the timeout fires', () => {
    vi.useFakeTimers()
    const attempt = startDiagnosticFetchTimeout(5000)

    expect(attempt.signal.aborted).toBe(false)
    expect(attempt.timedOut).toBe(false)

    vi.advanceTimersByTime(5000)

    expect(attempt.signal.aborted).toBe(true)
    expect(attempt.timedOut).toBe(true)
  })

  it('clears the timeout when disposed early', () => {
    vi.useFakeTimers()
    const attempt = startDiagnosticFetchTimeout(5000)

    attempt.dispose()
    expect(attempt.signal.aborted).toBe(true)
    expect(attempt.timedOut).toBe(false)

    vi.advanceTimersByTime(5000)
    expect(attempt.timedOut).toBe(false)
  })
})