import { describe, expect, it } from 'vitest';

import {
  canSubmitWalkthroughForm,
  hasAllWalkthroughRatings,
} from '@/business/walkthrough/validators';
import type { WalkthroughRatingDraft } from '@/business/walkthrough/mappers';

const completeRatings: WalkthroughRatingDraft = {
  attitude: 3,
  classroom_management: 3,
  cleanliness: 3,
  vibes: 3,
  team_dynamics: 3,
  emergency_exit: 3,
  lesson_plan: 3,
};

describe('walkthrough validators', () => {
  it('requires every walkthrough category rating before submission', () => {
    expect(hasAllWalkthroughRatings(completeRatings)).toBe(true);
    expect(hasAllWalkthroughRatings({ ...completeRatings, lesson_plan: undefined })).toBe(false);
  });

  it('requires staff, classroom, director, and complete ratings before submission', () => {
    expect(canSubmitWalkthroughForm({
      teacherName: '  Alex Rivera ',
      classroom: ' Room 4 ',
      directorName: ' Director ',
      ratings: completeRatings,
    })).toBe(true);

    expect(canSubmitWalkthroughForm({
      teacherName: '',
      classroom: 'Room 4',
      directorName: 'Director',
      ratings: completeRatings,
    })).toBe(false);

    expect(canSubmitWalkthroughForm({
      teacherName: 'Alex Rivera',
      classroom: 'Room 4',
      directorName: '   ',
      ratings: completeRatings,
    })).toBe(false);

    expect(canSubmitWalkthroughForm({
      teacherName: 'Alex Rivera',
      classroom: 'Room 4',
      directorName: 'Director',
      ratings: {},
    })).toBe(false);
  });
});
