website refactor
This commit is contained in:
@@ -60,7 +60,7 @@ export interface ProtestProps {
|
||||
|
||||
export class Protest extends Entity<string> {
|
||||
private constructor(private readonly props: ProtestProps) {
|
||||
super(props.id);}
|
||||
super(props.id.toString());}
|
||||
|
||||
static create(props: {
|
||||
id: string;
|
||||
@@ -172,7 +172,6 @@ export class Protest extends Entity<string> {
|
||||
return new Protest(protestProps);
|
||||
}
|
||||
|
||||
get id(): string { return this.props.id.toString(); }
|
||||
get raceId(): string { return this.props.raceId.toString(); }
|
||||
get protestingDriverId(): string { return this.props.protestingDriverId.toString(); }
|
||||
get accusedDriverId(): string { return this.props.accusedDriverId.toString(); }
|
||||
|
||||
@@ -47,27 +47,27 @@ describe('TeamRatingEvent', () => {
|
||||
});
|
||||
|
||||
it('should throw for missing dimension', () => {
|
||||
const { dimension: _dimension, ...rest } = validProps;
|
||||
const { dimension: _, ...rest } = validProps;
|
||||
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw for missing delta', () => {
|
||||
const { delta: _delta, ...rest } = validProps;
|
||||
const { delta: _, ...rest } = validProps;
|
||||
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw for missing source', () => {
|
||||
const { source: _source, ...rest } = validProps;
|
||||
const { source: _, ...rest } = validProps;
|
||||
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw for missing reason', () => {
|
||||
const { reason: _reason, ...rest } = validProps;
|
||||
const { reason: _, ...rest } = validProps;
|
||||
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw for missing visibility', () => {
|
||||
const { visibility: _visibility, ...rest } = validProps;
|
||||
const { visibility: _, ...rest } = validProps;
|
||||
expect(() => TeamRatingEvent.create(rest as typeof validProps)).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ export class ChampionshipStanding extends Entity<string> {
|
||||
resultsDropped: number;
|
||||
position: number;
|
||||
}) {
|
||||
super(props.id);
|
||||
const id = `${props.seasonId}-${props.championshipId}-${props.participant.id}`;
|
||||
super(id);
|
||||
this.seasonId = props.seasonId;
|
||||
this.championshipId = props.championshipId;
|
||||
this.participant = props.participant;
|
||||
@@ -31,7 +32,6 @@ export class ChampionshipStanding extends Entity<string> {
|
||||
this.resultsCounted = ResultsCount.create(props.resultsCounted);
|
||||
this.resultsDropped = ResultsCount.create(props.resultsDropped);
|
||||
this.position = Position.create(props.position);
|
||||
this.id = `${this.seasonId}-${this.championshipId}-${this.participant.id}`;
|
||||
}
|
||||
|
||||
static create(props: {
|
||||
|
||||
@@ -240,10 +240,10 @@ export class Penalty extends Entity<PenaltyId> {
|
||||
}
|
||||
}
|
||||
|
||||
equals(other: Entity<string>): boolean {
|
||||
if (!(other instanceof Penalty)) {
|
||||
equals(other?: Entity<PenaltyId>): boolean {
|
||||
if (!other || !(other instanceof Penalty)) {
|
||||
return false;
|
||||
}
|
||||
return this.id === other.id;
|
||||
return this.id.equals(other.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import {
|
||||
} from '@core/racing/domain/errors/RacingDomainError';
|
||||
|
||||
import { SeasonScoringConfig } from '@core/racing/domain/value-objects/SeasonScoringConfig';
|
||||
SeasonDropPolicy,
|
||||
} from '@core/racing/domain/value-objects/SeasonDropPolicy';
|
||||
import { SeasonDropPolicy } from '@core/racing/domain/value-objects/SeasonDropPolicy';
|
||||
import { SeasonStewardingConfig } from '@core/racing/domain/value-objects/SeasonStewardingConfig';
|
||||
import { Season, SeasonStatus } from '@core/racing/domain/entities/season/Season';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { DomainError } from '@core/shared/errors/DomainError';
|
||||
import type { CommonDomainErrorKind } from '@core/shared/errors/DomainError';
|
||||
import type { DomainError, CommonDomainErrorKind } from '@core/shared/errors/DomainError';
|
||||
|
||||
export abstract class RacingDomainError extends Error implements DomainError<CommonDomainErrorKind> {
|
||||
readonly type = 'domain' as const;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
RacingDomainValidationError,
|
||||
} from '../errors/RacingDomainError';
|
||||
|
||||
import {
|
||||
SeasonDropPolicy,
|
||||
type SeasonDropStrategy,
|
||||
} from './SeasonDropPolicy';
|
||||
|
||||
Reference in New Issue
Block a user