import { describe, it, expect } from 'vitest'
import {
  ToolingError,
  serviceUnavailable as _serviceUnavailable,
  permissionDenied as _permissionDenied,
  rateLimitExceeded as _rateLimitExceeded,
  apiError as _apiError
} from '../types'

describe('ToolingError', () => {
  describe('isRetryable', () => {
    it('returns true for retryable errors', () => {
      const retryableTypes = [
        'service_unavailable',
        'rate_limit_exceeded',
        'api_error',
        'network_error',
        'timeout_error',
        'server_unavailable'
      ]

      retryableTypes.forEach((type) => {
        const error = new ToolingError(type as unknown as string, 'Test')
        expect(error.isRetryable()).toBe(true)
      })
    })

    it('returns false for non-retryable errors', () => {
      const nonRetryableTypes = [
        'permission_denied',
        'adapter_not_found',
        'method_not_found',
        'tool_not_found',
        'credentials_missing',
        'credentials_invalid',
        'auth_error',
        'validation_error',
        'unknown_error'
      ]

      nonRetryableTypes.forEach((type) => {
        const error = new ToolingError(type as unknown as string, 'Test')
        expect(error.isRetryable()).toBe(false)
      })
    })
  })
})
