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

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

    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 Emma as first trainer', () => {
      expect(TRAINERS[0].id).toBe('emma')
      expect(TRAINERS[0].name).toBe('Emma')
      expect(TRAINERS[0].specialty).toBe('Full Body')
    })

    it('should have Jake as second trainer', () => {
      expect(TRAINERS[1].id).toBe('jake')
      expect(TRAINERS[1].name).toBe('Jake')
      expect(TRAINERS[1].specialty).toBe('Strength')
    })

    it('should have Mia as third trainer', () => {
      expect(TRAINERS[2].id).toBe('mia')
      expect(TRAINERS[2].name).toBe('Mia')
      expect(TRAINERS[2].specialty).toBe('Core')
    })

    it('should have Alex as fourth trainer', () => {
      expect(TRAINERS[3].id).toBe('alex')
      expect(TRAINERS[3].name).toBe('Alex')
      expect(TRAINERS[3].specialty).toBe('Cardio')
    })

    it('should have Sofia as fifth trainer', () => {
      expect(TRAINERS[4].id).toBe('sofia')
      expect(TRAINERS[4].name).toBe('Sofia')
      expect(TRAINERS[4].specialty).toBe('Recovery')
    })
  })

  describe('specialty coverage', () => {
    it('should cover all major workout types', () => {
      const specialties = TRAINERS.map(t => t.specialty)
      expect(specialties).toContain('Full Body')
      expect(specialties).toContain('Strength')
      expect(specialties).toContain('Core')
      expect(specialties).toContain('Cardio')
      expect(specialties).toContain('Recovery')
    })
  })

  describe('workout distribution', () => {
    it('should have Emma with most workouts', () => {
      const emma = TRAINERS.find(t => t.id === 'emma')
      expect(emma!.workoutCount).toBe(15)
    })

    it('should have Sofia with fewest workouts', () => {
      const sofia = TRAINERS.find(t => t.id === 'sofia')
      expect(sofia!.workoutCount).toBe(5)
    })

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