import { describe, it, expect } from 'vitest'; // --------------------------------------------------------------------------- // Logic extracted from the league home page component // --------------------------------------------------------------------------- type SeasonStatus = 'pre_draft' | 'draft' | 'active' | 'completed'; /** * Mirrors the isDraftOrPreDraft and draft-order-card visibility logic * from app/routes/leagues/$leagueId.tsx: * * const isDraftOrPreDraft = season?.status === "pre_draft" || season?.status === "draft"; * ... * {season && isDraftOrPreDraft && draftSlots.length > 0 && } */ function shouldShowDraftOrderCard( season: { status: SeasonStatus } | null, draftSlotCount: number ): boolean { if (!season) return false; const isDraftOrPreDraft = season.status === 'pre_draft' || season.status === 'draft'; return isDraftOrPreDraft && draftSlotCount > 0; } // --------------------------------------------------------------------------- // Tests // --------------------------------------------------------------------------- describe('Draft Order Card Visibility', () => { describe('visible states (pre_draft / draft)', () => { it('shows when status is pre_draft and draft slots are set', () => { expect(shouldShowDraftOrderCard({ status: 'pre_draft' }, 4)).toBe(true); }); it('shows when status is draft and draft slots are set', () => { expect(shouldShowDraftOrderCard({ status: 'draft' }, 4)).toBe(true); }); it('shows with a single draft slot', () => { expect(shouldShowDraftOrderCard({ status: 'pre_draft' }, 1)).toBe(true); }); }); describe('hidden states (active / completed)', () => { it('hides when status is active even if draft slots exist', () => { expect(shouldShowDraftOrderCard({ status: 'active' }, 4)).toBe(false); }); it('hides when status is completed even if draft slots exist', () => { expect(shouldShowDraftOrderCard({ status: 'completed' }, 4)).toBe(false); }); }); describe('no draft slots', () => { it('hides when no draft slots are set (pre_draft)', () => { expect(shouldShowDraftOrderCard({ status: 'pre_draft' }, 0)).toBe(false); }); it('hides when no draft slots are set (draft)', () => { expect(shouldShowDraftOrderCard({ status: 'draft' }, 0)).toBe(false); }); }); describe('no season', () => { it('hides when there is no season', () => { expect(shouldShowDraftOrderCard(null, 4)).toBe(false); }); }); });