website refactor

This commit is contained in:
2026-01-16 19:38:55 +01:00
parent 095885544b
commit 26fc726556
73 changed files with 232 additions and 213 deletions

View File

@@ -1,11 +1,12 @@
import { TeamRatingEvent } from './TeamRatingEvent';
import { describe, it, expect } from 'vitest';
import { TeamRatingEvent, type TeamRatingEventProps } from './TeamRatingEvent';
import { TeamRatingEventId } from '../value-objects/TeamRatingEventId';
import { TeamRatingDimensionKey } from '../value-objects/TeamRatingDimensionKey';
import { TeamRatingDelta } from '../value-objects/TeamRatingDelta';
import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError';
describe('TeamRatingEvent', () => {
const validProps = {
const validProps: TeamRatingEventProps = {
id: TeamRatingEventId.create('123e4567-e89b-12d3-a456-426614174000'),
teamId: 'team-123',
dimension: TeamRatingDimensionKey.create('driving'),
@@ -47,28 +48,43 @@ describe('TeamRatingEvent', () => {
});
it('should throw for missing dimension', () => {
const { dimension: _, ...rest } = validProps;
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
const props = { ...validProps };
// @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).dimension;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
});
it('should throw for missing delta', () => {
const { delta: _, ...rest } = validProps;
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
const props = { ...validProps };
// @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).delta;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
});
it('should throw for missing source', () => {
const { source: _, ...rest } = validProps;
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
const props = { ...validProps };
// @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).source;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
});
it('should throw for missing reason', () => {
const { reason: _, ...rest } = validProps;
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
const props = { ...validProps };
// @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).reason;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
});
it('should throw for missing visibility', () => {
const { visibility: _, ...rest } = validProps;
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
const props = { ...validProps };
// @ts-expect-error - testing validation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (props as any).visibility;
expect(() => TeamRatingEvent.create(props as unknown as TeamRatingEventProps)).toThrow(RacingDomainValidationError);
});
it('should throw for invalid weight', () => {