import { describe, it, expect } from 'vitest'; import { LeagueName } from './LeagueName'; describe('LeagueName', () => { it('should create valid name', () => { const name = LeagueName.create('Valid League Name'); expect(name.value).toBe('Valid League Name'); }); it('should trim whitespace', () => { const name = LeagueName.create('Valid Name'); expect(name.value).toBe('Valid Name'); }); it('should validate minimum length', () => { expect(() => LeagueName.create('AB')).toThrow('League name must be at least 3 characters'); }); it('should validate maximum length', () => { const longName = 'a'.repeat(65); expect(() => LeagueName.create(longName)).toThrow('League name must be 64 characters or less'); }); it('should validate required', () => { expect(() => LeagueName.create('')).toThrow('League name is required'); expect(() => LeagueName.create(' ')).toThrow('League name is required'); }); it('should validate pattern', () => { expect(() => LeagueName.create('_league')).toThrow('League name must start with a letter or number'); }); it('should validate forbidden patterns', () => { expect(() => LeagueName.create(' League ')).toThrow('League name cannot have leading/trailing spaces or multiple consecutive spaces'); expect(() => LeagueName.create('League Name')).toThrow('League name cannot have leading/trailing spaces or multiple consecutive spaces'); }); it('should validate without creating', () => { expect(LeagueName.validate('AB')).toEqual({ valid: false, error: 'League name must be at least 3 characters' }); expect(LeagueName.validate('Valid Name')).toEqual({ valid: true }); }); it('should tryCreate', () => { expect(LeagueName.tryCreate('Valid')).toBeInstanceOf(LeagueName); expect(LeagueName.tryCreate('AB')).toBeNull(); }); it('should have props', () => { const name = LeagueName.create('Test'); expect(name.props).toEqual({ value: 'Test' }); }); it('should toString', () => { const name = LeagueName.create('Test'); expect(name.toString()).toBe('Test'); }); it('equals', () => { const name1 = LeagueName.create('Test'); const name2 = LeagueName.create('Test'); const name3 = LeagueName.create('Different'); expect(name1.equals(name2)).toBe(true); expect(name1.equals(name3)).toBe(false); }); });