/**
 * Unit tests for SDK types
 */

import { describe, it, expect } from 'vitest';
import type {
  ProcessorType,
  Precision,
  BalancingStrategy,
  TaskPriority,
  JobStatus,
  SynorConfig,
  MatMulRequest,
  InferenceRequest,
} from '../types';

describe('Types', () => {
  describe('ProcessorType', () => {
    it('should accept valid processor types', () => {
      const processors: ProcessorType[] = [
        'cpu', 'gpu', 'tpu', 'npu', 'lpu', 'fpga', 'dsp', 'webgpu', 'wasm', 'auto'
      ];
      expect(processors).toHaveLength(10);
    });
  });

  describe('Precision', () => {
    it('should accept valid precision types', () => {
      const precisions: Precision[] = [
        'fp64', 'fp32', 'fp16', 'bf16', 'int8', 'int4'
      ];
      expect(precisions).toHaveLength(6);
    });
  });

  describe('BalancingStrategy', () => {
    it('should accept valid balancing strategies', () => {
      const strategies: BalancingStrategy[] = [
        'cost', 'latency', 'energy', 'throughput', 'auto'
      ];
      expect(strategies).toHaveLength(5);
    });
  });

  describe('TaskPriority', () => {
    it('should accept valid priority levels', () => {
      const priorities: TaskPriority[] = [
        'critical', 'high', 'normal', 'low', 'background'
      ];
      expect(priorities).toHaveLength(5);
    });
  });

  describe('JobStatus', () => {
    it('should accept valid job statuses', () => {
      const statuses: JobStatus[] = [
        'pending', 'queued', 'running', 'completed', 'failed', 'cancelled'
      ];
      expect(statuses).toHaveLength(6);
    });
  });

  describe('SynorConfig', () => {
    it('should create valid config object', () => {
      const config: SynorConfig = {
        apiKey: 'test-api-key',
        baseUrl: 'https://api.synor.io/compute/v1',
        timeout: 30000,
      };
      expect(config.apiKey).toBe('test-api-key');
      expect(config.baseUrl).toBeDefined();
    });

    it('should allow optional fields', () => {
      const config: SynorConfig = {
        apiKey: 'test-api-key',
      };
      expect(config.apiKey).toBe('test-api-key');
    });
  });

  describe('MatMulRequest', () => {
    it('should create valid matmul request', () => {
      const request: MatMulRequest = {
        a: { data: 'base64', shape: [2, 3], dtype: 'fp32' },
        b: { data: 'base64', shape: [3, 4], dtype: 'fp32' },
        precision: 'fp16',
        processor: 'gpu',
      };
      expect(request.a.shape).toEqual([2, 3]);
      expect(request.b.shape).toEqual([3, 4]);
    });
  });

  describe('InferenceRequest', () => {
    it('should create valid inference request', () => {
      const request: InferenceRequest = {
        model: 'llama-3-70b',
        prompt: 'Hello, world!',
        maxTokens: 256,
        temperature: 0.7,
        topP: 0.9,
        topK: 50,
      };
      expect(request.model).toBe('llama-3-70b');
      expect(request.maxTokens).toBe(256);
    });
  });
});
