import { describe, it, expect } from 'vitest'
import { TRAINERS } from '../../shared/data/trainers'

describe('trainers data', () => {
  describe('TRAINERS structure', () => {
    it('should have exactly 2 trainers', () => {
      expect(TRAINERS).toHaveLength(2)
    })

    it('should have all required properties', () => {
      TRAINERS.forEach(trainer => {
        expect(trainer.id).toBeDefined()
        expect(trainer.name).toBeDefined()
        expect(trainer.specialty).toBeDefined()
        expect(trainer.color).toBeDefined()
        expect(trainer.workoutCount).toBeDefined()
      })
    })

    it('should have unique trainer IDs', () => {
      const ids = TRAINERS.map(t => t.id)
      const uniqueIds = new Set(ids)
      expect(uniqueIds.size).toBe(ids.length)
    })

    it('should have unique trainer names', () => {
      const names = TRAINERS.map(t => t.name)
      const uniqueNames = new Set(names)
      expect(uniqueNames.size).toBe(names.length)
    })

    it('should have valid hex colors', () => {
      const hexPattern = /^#[0-9A-Fa-f]{6}$/
      TRAINERS.forEach(trainer => {
        expect(trainer.color).toMatch(hexPattern)
      })
    })

    it('should have positive workout counts', () => {
      TRAINERS.forEach(trainer => {
        expect(trainer.workoutCount).toBeGreaterThan(0)
      })
    })
  })

  describe('specific trainers', () => {
    it('should have Félia as first trainer', () => {
      expect(TRAINERS[0].id).toBe('felia')
      expect(TRAINERS[0].name).toBe('Félia')
      expect(TRAINERS[0].gender).toBe('female')
      expect(TRAINERS[0].specialty).toBe('Core')
    })

    it('should have Félix as second trainer', () => {
      expect(TRAINERS[1].id).toBe('felix')
      expect(TRAINERS[1].name).toBe('Félix')
      expect(TRAINERS[1].gender).toBe('male')
      expect(TRAINERS[1].specialty).toBe('Strength')
    })
  })

  describe('gender distribution', () => {
    it('should have exactly 1 male and 1 female trainer', () => {
      const males = TRAINERS.filter(t => t.gender === 'male')
      const females = TRAINERS.filter(t => t.gender === 'female')
      expect(males).toHaveLength(1)
      expect(females).toHaveLength(1)
    })
  })

  describe('specialty coverage', () => {
    it('should cover core workout types', () => {
      const specialties = TRAINERS.map(t => t.specialty)
      expect(specialties).toContain('Core')
      expect(specialties).toContain('Strength')
    })
  })

  describe('workout distribution', () => {
    it('should have total workout count of 30', () => {
      const total = TRAINERS.reduce((sum, t) => sum + t.workoutCount, 0)
      expect(total).toBe(30)
    })
  })
})
