/**
 * Contract test for IPlatformAdapter.setProxyConfig()
 *
 * This test validates the platform adapter proxy functionality
 * according to the contract specification. Tests MUST FAIL until implementation is complete.
 */

import { describe, test, expect, beforeEach, jest } from '@jest/globals'

// Import types that will be implemented
import type { IPlatformAdapter, ProxyConfig, ProxyStatus } from '@/types/platformAdapter'

describe('IPlatformAdapter.setProxyConfig() Contract', () => {
  let adapter: IPlatformAdapter

  beforeEach(() => {
    // This will fail until platform adapters are implemented
    // eslint-disable-next-line @typescript-eslint/no-require-imports
    const { PacificaHttpAdapter } = require('@/adapters/pacifica/PacificaHttpAdapter')
    adapter = new PacificaHttpAdapter({
      platform: 'pacifica',
      baseUrl: 'https://api.pacifica.fi',
      authConfig: { type: 'signature' }
    })
  })

  describe('Proxy Configuration', () => {
    test('should set HTTP proxy configuration', async () => {
      const proxyConfig: ProxyConfig = {
        enabled: true,
        protocol: 'http',
        host: 'proxy.example.com',
        port: 8080,
        auth: {
          username: 'user',
          password: 'pass'
        }
      }

      await adapter.setProxyConfig(proxyConfig)

      const status: ProxyStatus = await adapter.getProxyStatus()
      expect(status.enabled).toBe(true)
      expect(status.host).toBe('proxy.example.com')
      expect(status.port).toBe(8080)
    })

    test('should disable proxy when config is null', async () => {
      await adapter.setProxyConfig(null)

      const status: ProxyStatus = await adapter.getProxyStatus()
      expect(status.enabled).toBe(false)
    })
  })
})