import { describe, it, expect, vi, beforeEach } from 'vitest';
import { educationService } from './educationService';

describe('educationService', () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  describe('getCatalog', () => {
    it('should return catalog courses', async () => {
      const courses = await educationService.getCatalog();

      expect(courses).toBeDefined();
      expect(Array.isArray(courses)).toBe(true);
      expect(courses.length).toBeGreaterThan(0);
      expect(courses[0]).toHaveProperty('id');
      expect(courses[0]).toHaveProperty('title');
      expect(courses[0]).toHaveProperty('instructor');
    });
  });

  describe('getMyCourses', () => {
    it('should return user courses', async () => {
      const courses = await educationService.getMyCourses();

      expect(courses).toBeDefined();
      expect(Array.isArray(courses)).toBe(true);
      expect(courses.length).toBeGreaterThan(0);
      expect(courses[0]).toHaveProperty('id');
      expect(courses[0]).toHaveProperty('title');
      expect(courses[0]).toHaveProperty('progress');
    });
  });

  describe('enroll', () => {
    it('should enroll in a course', async () => {
      const result = await educationService.enroll('course-1');

      expect(result).toBeDefined();
      expect(result.success).toBe(true);
    });
  });
});
