import { describe, expect, it } from 'vitest'; import { RacingDomainValidationError, } from '../errors/RacingDomainError'; import { SeasonScoringConfig } from './SeasonScoringConfig'; describe('SeasonScoringConfig', () => { it('constructs from preset id and customScoringEnabled', () => { const config = new SeasonScoringConfig({ scoringPresetId: 'club-default', customScoringEnabled: true, }); expect(config.scoringPresetId).toBe('club-default'); expect(config.customScoringEnabled).toBe(true); expect(config.props.scoringPresetId).toBe('club-default'); expect(config.props.customScoringEnabled).toBe(true); }); it('normalizes customScoringEnabled to false when omitted', () => { const config = new SeasonScoringConfig({ scoringPresetId: 'sprint-main-driver', }); expect(config.customScoringEnabled).toBe(false); expect(config.props.customScoringEnabled).toBeUndefined(); }); it('throws when scoringPresetId is empty', () => { expect( () => new SeasonScoringConfig({ scoringPresetId: ' ', }), ).toThrow(RacingDomainValidationError); }); it('equals compares by preset id and customScoringEnabled', () => { const a = new SeasonScoringConfig({ scoringPresetId: 'club-default', customScoringEnabled: false, }); const b = new SeasonScoringConfig({ scoringPresetId: 'club-default', customScoringEnabled: false, }); const c = new SeasonScoringConfig({ scoringPresetId: 'club-default', customScoringEnabled: true, }); expect(a.equals(b)).toBe(true); expect(a.equals(c)).toBe(false); }); });