import { describe, expect, it } from 'vitest'; import { LeagueDescription } from './LeagueDescription'; describe('LeagueDescription', () => { it('should create valid description', () => { const desc = LeagueDescription.create('This is a valid league description with enough characters.'); expect(desc.value).toBe('This is a valid league description with enough characters.'); }); it('should trim whitespace', () => { const desc = LeagueDescription.create(' This is a valid description with enough characters to pass validation. '); expect(desc.value).toBe('This is a valid description with enough characters to pass validation.'); }); it('should validate minimum length', () => { expect(() => LeagueDescription.create('Short')).toThrow('Description must be at least 20 characters'); }); it('should validate maximum length', () => { const longDesc = 'a'.repeat(1001); expect(() => LeagueDescription.create(longDesc)).toThrow('Description must be 1000 characters or less'); }); it('should validate required', () => { expect(() => LeagueDescription.create('')).toThrow('Description is required'); expect(() => LeagueDescription.create(' ')).toThrow('Description is required'); }); it('should check recommended length', () => { expect(LeagueDescription.isRecommendedLength('Short desc')).toBe(false); expect(LeagueDescription.isRecommendedLength('This is a longer description that meets the recommended length.')).toBe(true); }); it('should validate without creating', () => { expect(LeagueDescription.validate('Valid')).toEqual({ valid: false, error: 'Description must be at least 20 characters — tell drivers what makes your league special' }); expect(LeagueDescription.validate('This is a valid description.')).toEqual({ valid: true }); }); it('should tryCreate', () => { expect(LeagueDescription.tryCreate('This is a valid description with enough characters.')).toBeInstanceOf(LeagueDescription); expect(LeagueDescription.tryCreate('Short')).toBeNull(); }); it('should have props', () => { const desc = LeagueDescription.create('This is a test description with enough characters.'); expect(desc.props).toEqual({ value: 'This is a test description with enough characters.' }); }); it('should toString', () => { const desc = LeagueDescription.create('This is a test description.'); expect(desc.toString()).toBe('This is a test description.'); }); it('equals', () => { const desc1 = LeagueDescription.create('This is a test description.'); const desc2 = LeagueDescription.create('This is a test description.'); const desc3 = LeagueDescription.create('This is a different description with enough characters.'); expect(desc1.equals(desc2)).toBe(true); expect(desc1.equals(desc3)).toBe(false); }); });