code quality
This commit is contained in:
@@ -521,7 +521,9 @@
|
|||||||
],
|
],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2022,
|
"ecmaVersion": 2022,
|
||||||
"sourceType": "module"
|
"sourceType": "module",
|
||||||
|
"project": "./tsconfig.eslint.json",
|
||||||
|
"tsconfigRootDir": "."
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"boundaries/elements": [
|
"boundaries/elements": [
|
||||||
|
|||||||
1
artifacts/verify/20260125T220700Z/core.eslint.json
Normal file
1
artifacts/verify/20260125T220700Z/core.eslint.json
Normal file
File diff suppressed because one or more lines are too long
@@ -8,13 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
|
import type { Mock } from 'vitest';
|
||||||
import { GetDashboardUseCase } from './GetDashboardUseCase';
|
import { GetDashboardUseCase } from './GetDashboardUseCase';
|
||||||
import { ValidationError } from '../../../shared/errors/ValidationError';
|
import { ValidationError } from '../../../shared/errors/ValidationError';
|
||||||
import { DriverNotFoundError } from '../../domain/errors/DriverNotFoundError';
|
import { DriverNotFoundError } from '../../domain/errors/DriverNotFoundError';
|
||||||
import { DashboardRepository } from '../ports/DashboardRepository';
|
import { DashboardRepository, DriverData, RaceData } from '../ports/DashboardRepository';
|
||||||
import { DashboardEventPublisher } from '../ports/DashboardEventPublisher';
|
import { DashboardEventPublisher } from '../ports/DashboardEventPublisher';
|
||||||
import { Logger } from '../../../shared/domain/Logger';
|
import { Logger } from '../../../shared/domain/Logger';
|
||||||
import { DriverData, RaceData, LeagueStandingData, ActivityData } from '../ports/DashboardRepository';
|
|
||||||
|
|
||||||
describe('GetDashboardUseCase', () => {
|
describe('GetDashboardUseCase', () => {
|
||||||
let mockDriverRepository: DashboardRepository;
|
let mockDriverRepository: DashboardRepository;
|
||||||
@@ -120,7 +120,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
it('should throw DriverNotFoundError when driverRepository.findDriverById returns null', async () => {
|
it('should throw DriverNotFoundError when driverRepository.findDriverById returns null', async () => {
|
||||||
// Given
|
// Given
|
||||||
const query = { driverId: 'driver-123' };
|
const query = { driverId: 'driver-123' };
|
||||||
(mockDriverRepository.findDriverById as any).mockResolvedValue(null);
|
(mockDriverRepository.findDriverById as Mock).mockResolvedValue(null);
|
||||||
|
|
||||||
// When & Then
|
// When & Then
|
||||||
await expect(useCase.execute(query)).rejects.toThrow(DriverNotFoundError);
|
await expect(useCase.execute(query)).rejects.toThrow(DriverNotFoundError);
|
||||||
@@ -143,7 +143,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
const query = { driverId: 'driver-123' };
|
const query = { driverId: 'driver-123' };
|
||||||
|
|
||||||
// Mock driver exists
|
// Mock driver exists
|
||||||
(mockDriverRepository.findDriverById as any).mockResolvedValue({
|
(mockDriverRepository.findDriverById as Mock).mockResolvedValue({
|
||||||
id: 'driver-123',
|
id: 'driver-123',
|
||||||
name: 'Test Driver',
|
name: 'Test Driver',
|
||||||
rating: 1500,
|
rating: 1500,
|
||||||
@@ -155,7 +155,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
} as DriverData);
|
} as DriverData);
|
||||||
|
|
||||||
// Mock races with missing trackName
|
// Mock races with missing trackName
|
||||||
(mockRaceRepository.getUpcomingRaces as any).mockResolvedValue([
|
(mockRaceRepository.getUpcomingRaces as Mock).mockResolvedValue([
|
||||||
{
|
{
|
||||||
id: 'race-1',
|
id: 'race-1',
|
||||||
trackName: '', // Missing trackName
|
trackName: '', // Missing trackName
|
||||||
@@ -170,8 +170,8 @@ describe('GetDashboardUseCase', () => {
|
|||||||
},
|
},
|
||||||
] as RaceData[]);
|
] as RaceData[]);
|
||||||
|
|
||||||
(mockLeagueRepository.getLeagueStandings as any).mockResolvedValue([]);
|
(mockLeagueRepository.getLeagueStandings as Mock).mockResolvedValue([]);
|
||||||
(mockActivityRepository.getRecentActivity as any).mockResolvedValue([]);
|
(mockActivityRepository.getRecentActivity as Mock).mockResolvedValue([]);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
const result = await useCase.execute(query);
|
const result = await useCase.execute(query);
|
||||||
@@ -186,7 +186,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
const query = { driverId: 'driver-123' };
|
const query = { driverId: 'driver-123' };
|
||||||
|
|
||||||
// Mock driver exists
|
// Mock driver exists
|
||||||
(mockDriverRepository.findDriverById as any).mockResolvedValue({
|
(mockDriverRepository.findDriverById as Mock).mockResolvedValue({
|
||||||
id: 'driver-123',
|
id: 'driver-123',
|
||||||
name: 'Test Driver',
|
name: 'Test Driver',
|
||||||
rating: 1500,
|
rating: 1500,
|
||||||
@@ -198,7 +198,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
} as DriverData);
|
} as DriverData);
|
||||||
|
|
||||||
// Mock races with past dates
|
// Mock races with past dates
|
||||||
(mockRaceRepository.getUpcomingRaces as any).mockResolvedValue([
|
(mockRaceRepository.getUpcomingRaces as Mock).mockResolvedValue([
|
||||||
{
|
{
|
||||||
id: 'race-1',
|
id: 'race-1',
|
||||||
trackName: 'Track A',
|
trackName: 'Track A',
|
||||||
@@ -213,8 +213,8 @@ describe('GetDashboardUseCase', () => {
|
|||||||
},
|
},
|
||||||
] as RaceData[]);
|
] as RaceData[]);
|
||||||
|
|
||||||
(mockLeagueRepository.getLeagueStandings as any).mockResolvedValue([]);
|
(mockLeagueRepository.getLeagueStandings as Mock).mockResolvedValue([]);
|
||||||
(mockActivityRepository.getRecentActivity as any).mockResolvedValue([]);
|
(mockActivityRepository.getRecentActivity as Mock).mockResolvedValue([]);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
const result = await useCase.execute(query);
|
const result = await useCase.execute(query);
|
||||||
@@ -229,7 +229,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
const query = { driverId: 'driver-123' };
|
const query = { driverId: 'driver-123' };
|
||||||
|
|
||||||
// Mock driver exists
|
// Mock driver exists
|
||||||
(mockDriverRepository.findDriverById as any).mockResolvedValue({
|
(mockDriverRepository.findDriverById as Mock).mockResolvedValue({
|
||||||
id: 'driver-123',
|
id: 'driver-123',
|
||||||
name: 'Test Driver',
|
name: 'Test Driver',
|
||||||
rating: 1500,
|
rating: 1500,
|
||||||
@@ -241,7 +241,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
} as DriverData);
|
} as DriverData);
|
||||||
|
|
||||||
// Mock races with various invalid states
|
// Mock races with various invalid states
|
||||||
(mockRaceRepository.getUpcomingRaces as any).mockResolvedValue([
|
(mockRaceRepository.getUpcomingRaces as Mock).mockResolvedValue([
|
||||||
{
|
{
|
||||||
id: 'race-1',
|
id: 'race-1',
|
||||||
trackName: '', // Missing trackName
|
trackName: '', // Missing trackName
|
||||||
@@ -262,8 +262,8 @@ describe('GetDashboardUseCase', () => {
|
|||||||
},
|
},
|
||||||
] as RaceData[]);
|
] as RaceData[]);
|
||||||
|
|
||||||
(mockLeagueRepository.getLeagueStandings as any).mockResolvedValue([]);
|
(mockLeagueRepository.getLeagueStandings as Mock).mockResolvedValue([]);
|
||||||
(mockActivityRepository.getRecentActivity as any).mockResolvedValue([]);
|
(mockActivityRepository.getRecentActivity as Mock).mockResolvedValue([]);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
const result = await useCase.execute(query);
|
const result = await useCase.execute(query);
|
||||||
@@ -278,7 +278,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
const query = { driverId: 'driver-123' };
|
const query = { driverId: 'driver-123' };
|
||||||
|
|
||||||
// Mock driver exists
|
// Mock driver exists
|
||||||
(mockDriverRepository.findDriverById as any).mockResolvedValue({
|
(mockDriverRepository.findDriverById as Mock).mockResolvedValue({
|
||||||
id: 'driver-123',
|
id: 'driver-123',
|
||||||
name: 'Test Driver',
|
name: 'Test Driver',
|
||||||
rating: 1500,
|
rating: 1500,
|
||||||
@@ -290,7 +290,7 @@ describe('GetDashboardUseCase', () => {
|
|||||||
} as DriverData);
|
} as DriverData);
|
||||||
|
|
||||||
// Mock races with valid data
|
// Mock races with valid data
|
||||||
(mockRaceRepository.getUpcomingRaces as any).mockResolvedValue([
|
(mockRaceRepository.getUpcomingRaces as Mock).mockResolvedValue([
|
||||||
{
|
{
|
||||||
id: 'race-1',
|
id: 'race-1',
|
||||||
trackName: 'Track A',
|
trackName: 'Track A',
|
||||||
@@ -305,8 +305,8 @@ describe('GetDashboardUseCase', () => {
|
|||||||
},
|
},
|
||||||
] as RaceData[]);
|
] as RaceData[]);
|
||||||
|
|
||||||
(mockLeagueRepository.getLeagueStandings as any).mockResolvedValue([]);
|
(mockLeagueRepository.getLeagueStandings as Mock).mockResolvedValue([]);
|
||||||
(mockActivityRepository.getRecentActivity as any).mockResolvedValue([]);
|
(mockActivityRepository.getRecentActivity as Mock).mockResolvedValue([]);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
const result = await useCase.execute(query);
|
const result = await useCase.execute(query);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { CheckApiHealthUseCase, CheckApiHealthUseCasePorts } from './CheckApiHealthUseCase';
|
import { CheckApiHealthUseCase } from './CheckApiHealthUseCase';
|
||||||
import { HealthCheckQuery, HealthCheckResult } from '../ports/HealthCheckQuery';
|
import { HealthCheckQuery, HealthCheckResult } from '../ports/HealthCheckQuery';
|
||||||
import { HealthEventPublisher } from '../ports/HealthEventPublisher';
|
import { HealthEventPublisher } from '../ports/HealthEventPublisher';
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* This Use Case orchestrates the retrieval of connection status information.
|
* This Use Case orchestrates the retrieval of connection status information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { HealthCheckQuery, ConnectionHealth, ConnectionStatus } from '../ports/HealthCheckQuery';
|
import { HealthCheckQuery, ConnectionStatus } from '../ports/HealthCheckQuery';
|
||||||
|
|
||||||
export interface GetConnectionStatusUseCasePorts {
|
export interface GetConnectionStatusUseCasePorts {
|
||||||
healthCheckAdapter: HealthCheckQuery;
|
healthCheckAdapter: HealthCheckQuery;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
import { GetUserRatingLedgerQueryHandler } from './GetUserRatingLedgerQuery';
|
import { GetUserRatingLedgerQueryHandler } from './GetUserRatingLedgerQuery';
|
||||||
import { RatingEventRepository } from '../../domain/repositories/RatingEventRepository';
|
import { RatingEventRepository, RatingEventFilter } from '../../domain/repositories/RatingEventRepository';
|
||||||
|
|
||||||
// Mock repository
|
// Mock repository
|
||||||
const createMockRepository = () => ({
|
const createMockRepository = () => ({
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
import { CastAdminVoteUseCase } from './CastAdminVoteUseCase';
|
import { CastAdminVoteUseCase } from './CastAdminVoteUseCase';
|
||||||
import { AdminVoteSessionRepository } from '../../domain/repositories/AdminVoteSessionRepository';
|
|
||||||
import { AdminVoteSession } from '../../domain/entities/AdminVoteSession';
|
|
||||||
|
|
||||||
// Mock repository
|
// Mock repository
|
||||||
const createMockRepository = () => ({
|
const createMockRepository = () => ({
|
||||||
@@ -55,7 +53,7 @@ describe('CastAdminVoteUseCase', () => {
|
|||||||
const result = await useCase.execute({
|
const result = await useCase.execute({
|
||||||
voteSessionId: 'session-123',
|
voteSessionId: 'session-123',
|
||||||
voterId: 'voter-123',
|
voterId: 'voter-123',
|
||||||
positive: 'true' as any,
|
positive: 'true' as unknown as boolean,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LeagueRepository } from '../ports/LeagueRepository';
|
import { LeagueRepository } from '../ports/LeagueRepository';
|
||||||
import { DriverRepository } from '../ports/DriverRepository';
|
import { DriverRepository } from '../../../racing/domain/repositories/DriverRepository';
|
||||||
import { EventPublisher } from '../ports/EventPublisher';
|
import { EventPublisher } from '../../../shared/ports/EventPublisher';
|
||||||
import { ApproveMembershipRequestCommand } from '../ports/ApproveMembershipRequestCommand';
|
import { ApproveMembershipRequestCommand } from '../ports/ApproveMembershipRequestCommand';
|
||||||
|
|
||||||
export class ApproveMembershipRequestUseCase {
|
export class ApproveMembershipRequestUseCase {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { LeagueRepository } from '../ports/LeagueRepository';
|
import { LeagueRepository } from '../ports/LeagueRepository';
|
||||||
import { DriverRepository } from '../ports/DriverRepository';
|
import { DriverRepository } from '../../../racing/domain/repositories/DriverRepository';
|
||||||
import { LeagueEventPublisher } from '../ports/LeagueEventPublisher';
|
import { LeagueEventPublisher } from '../ports/LeagueEventPublisher';
|
||||||
import { DemoteAdminCommand } from '../ports/DemoteAdminCommand';
|
import { DemoteAdminCommand } from '../ports/DemoteAdminCommand';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LeagueRepository, LeagueData } from '../ports/LeagueRepository';
|
import { LeagueRepository, LeagueData } from '../ports/LeagueRepository';
|
||||||
import { DriverRepository } from '../ports/DriverRepository';
|
import { DriverRepository } from '../../../racing/domain/repositories/DriverRepository';
|
||||||
import { EventPublisher } from '../ports/EventPublisher';
|
import { EventPublisher } from '../../../shared/ports/EventPublisher';
|
||||||
import { JoinLeagueCommand } from '../ports/JoinLeagueCommand';
|
import { JoinLeagueCommand } from '../ports/JoinLeagueCommand';
|
||||||
|
|
||||||
export class JoinLeagueUseCase {
|
export class JoinLeagueUseCase {
|
||||||
@@ -16,7 +16,7 @@ export class JoinLeagueUseCase {
|
|||||||
throw new Error('League not found');
|
throw new Error('League not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const driver = await this.driverRepository.findDriverById(command.driverId);
|
const driver = await this.driverRepository.findById(command.driverId);
|
||||||
if (!driver) {
|
if (!driver) {
|
||||||
throw new Error('Driver not found');
|
throw new Error('Driver not found');
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ export class JoinLeagueUseCase {
|
|||||||
{
|
{
|
||||||
id: `request-${Date.now()}`,
|
id: `request-${Date.now()}`,
|
||||||
driverId: command.driverId,
|
driverId: command.driverId,
|
||||||
name: driver.name,
|
name: driver.name.toString(),
|
||||||
requestDate: new Date(),
|
requestDate: new Date(),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -34,7 +34,7 @@ export class JoinLeagueUseCase {
|
|||||||
await this.leagueRepository.addLeagueMembers(command.leagueId, [
|
await this.leagueRepository.addLeagueMembers(command.leagueId, [
|
||||||
{
|
{
|
||||||
driverId: command.driverId,
|
driverId: command.driverId,
|
||||||
name: driver.name,
|
name: driver.name.toString(),
|
||||||
role: 'member',
|
role: 'member',
|
||||||
joinDate: new Date(),
|
joinDate: new Date(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LeagueRepository } from '../ports/LeagueRepository';
|
import { LeagueRepository } from '../ports/LeagueRepository';
|
||||||
import { DriverRepository } from '../ports/DriverRepository';
|
import { DriverRepository } from '../../../racing/domain/repositories/DriverRepository';
|
||||||
import { EventPublisher } from '../ports/EventPublisher';
|
import { EventPublisher } from '../../../shared/ports/EventPublisher';
|
||||||
import { LeaveLeagueCommand } from '../ports/LeaveLeagueCommand';
|
import { LeaveLeagueCommand } from '../ports/LeaveLeagueCommand';
|
||||||
|
|
||||||
export class LeaveLeagueUseCase {
|
export class LeaveLeagueUseCase {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LeagueRepository } from '../ports/LeagueRepository';
|
import { LeagueRepository } from '../ports/LeagueRepository';
|
||||||
import { DriverRepository } from '../ports/DriverRepository';
|
import { DriverRepository } from '../../../racing/domain/repositories/DriverRepository';
|
||||||
import { EventPublisher } from '../ports/EventPublisher';
|
import { EventPublisher } from '../../../shared/ports/EventPublisher';
|
||||||
import { PromoteMemberCommand } from '../ports/PromoteMemberCommand';
|
import { PromoteMemberCommand } from '../ports/PromoteMemberCommand';
|
||||||
|
|
||||||
export class PromoteMemberUseCase {
|
export class PromoteMemberUseCase {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { LeagueRepository } from '../ports/LeagueRepository';
|
import { LeagueRepository } from '../ports/LeagueRepository';
|
||||||
import { DriverRepository } from '../ports/DriverRepository';
|
import { DriverRepository } from '../../../racing/domain/repositories/DriverRepository';
|
||||||
import { LeagueEventPublisher } from '../ports/LeagueEventPublisher';
|
import { LeagueEventPublisher } from '../ports/LeagueEventPublisher';
|
||||||
import { RejectMembershipRequestCommand } from '../ports/RejectMembershipRequestCommand';
|
import { RejectMembershipRequestCommand } from '../ports/RejectMembershipRequestCommand';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LeagueRepository } from '../ports/LeagueRepository';
|
import { LeagueRepository } from '../ports/LeagueRepository';
|
||||||
import { DriverRepository } from '../ports/DriverRepository';
|
import { DriverRepository } from '../../../racing/domain/repositories/DriverRepository';
|
||||||
import { EventPublisher } from '../ports/EventPublisher';
|
import { EventPublisher } from '../../../shared/ports/EventPublisher';
|
||||||
import { RemoveMemberCommand } from '../ports/RemoveMemberCommand';
|
import { RemoveMemberCommand } from '../ports/RemoveMemberCommand';
|
||||||
|
|
||||||
export class RemoveMemberUseCase {
|
export class RemoveMemberUseCase {
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ export class CompleteRaceUseCase {
|
|||||||
startPosition,
|
startPosition,
|
||||||
fastestLap,
|
fastestLap,
|
||||||
incidents,
|
incidents,
|
||||||
|
points: 0,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export type ImportRaceResultDTO = {
|
|||||||
fastestLap: number;
|
fastestLap: number;
|
||||||
incidents: number;
|
incidents: number;
|
||||||
startPosition: number;
|
startPosition: number;
|
||||||
|
points: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ImportRaceResultsApiInput = {
|
export type ImportRaceResultsApiInput = {
|
||||||
@@ -145,6 +146,7 @@ export class ImportRaceResultsApiUseCase {
|
|||||||
fastestLap: dto.fastestLap,
|
fastestLap: dto.fastestLap,
|
||||||
incidents: dto.incidents,
|
incidents: dto.incidents,
|
||||||
startPosition: dto.startPosition,
|
startPosition: dto.startPosition,
|
||||||
|
points: dto.points,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export type ImportRaceResultRow = {
|
|||||||
fastestLap: number;
|
fastestLap: number;
|
||||||
incidents: number;
|
incidents: number;
|
||||||
startPosition: number;
|
startPosition: number;
|
||||||
|
points: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ImportRaceResultsInput = {
|
export type ImportRaceResultsInput = {
|
||||||
@@ -127,6 +128,7 @@ export class ImportRaceResultsUseCase {
|
|||||||
fastestLap: row.fastestLap,
|
fastestLap: row.fastestLap,
|
||||||
incidents: row.incidents,
|
incidents: row.incidents,
|
||||||
startPosition: row.startPosition,
|
startPosition: row.startPosition,
|
||||||
|
points: row.points,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export class RaceResultGenerator {
|
|||||||
startPosition,
|
startPosition,
|
||||||
fastestLap,
|
fastestLap,
|
||||||
incidents,
|
incidents,
|
||||||
|
points: 0,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ describe('Result', () => {
|
|||||||
it('should stop chaining on first error', () => {
|
it('should stop chaining on first error', () => {
|
||||||
const result = Result.ok(2)
|
const result = Result.ok(2)
|
||||||
.andThen((x) => Result.ok(x * 3))
|
.andThen((x) => Result.ok(x * 3))
|
||||||
.andThen((x) => Result.err(new Error('stopped here')))
|
.andThen((x) => Result.err(new Error(`stopped at ${x}`)))
|
||||||
.andThen((x) => Result.ok(x + 1)); // This should not execute
|
.andThen((x) => Result.ok(x + 1)); // This should not execute
|
||||||
|
|
||||||
expect(result.isErr()).toBe(true);
|
expect(result.isErr()).toBe(true);
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ describe('ValueObject', () => {
|
|||||||
it('should return false when comparing with undefined', () => {
|
it('should return false when comparing with undefined', () => {
|
||||||
const vo = new TestValueObject('test', 42);
|
const vo = new TestValueObject('test', 42);
|
||||||
// Testing that equals method handles undefined gracefully
|
// Testing that equals method handles undefined gracefully
|
||||||
const result = vo.equals as any;
|
const result = vo.equals as (other: unknown) => boolean;
|
||||||
expect(result(undefined)).toBe(false);
|
expect(result(undefined)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false when comparing with null', () => {
|
it('should return false when comparing with null', () => {
|
||||||
const vo = new TestValueObject('test', 42);
|
const vo = new TestValueObject('test', 42);
|
||||||
// Testing that equals method handles null gracefully
|
// Testing that equals method handles null gracefully
|
||||||
const result = vo.equals as any;
|
const result = vo.equals as (other: unknown) => boolean;
|
||||||
expect(result(null)).toBe(false);
|
expect(result(null)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
export * from './DomainEvent';
|
|
||||||
export * from './Entity';
|
|
||||||
export * from './Logger';
|
|
||||||
export * from './Option';
|
|
||||||
export * from './Result';
|
|
||||||
export * from './Service';
|
|
||||||
export * from './ValueObject';
|
|
||||||
@@ -92,16 +92,16 @@ describe('ApplicationErrorCode', () => {
|
|||||||
// This test verifies the type compatibility
|
// This test verifies the type compatibility
|
||||||
type MyErrorCodes = 'USER_NOT_FOUND' | 'VALIDATION_ERROR' | 'PERMISSION_DENIED';
|
type MyErrorCodes = 'USER_NOT_FOUND' | 'VALIDATION_ERROR' | 'PERMISSION_DENIED';
|
||||||
|
|
||||||
const userNotFound: ApplicationErrorCode<'USER_NOT_FOUND'> = {
|
const userNotFound: ApplicationErrorCode<MyErrorCodes> = {
|
||||||
code: 'USER_NOT_FOUND'
|
code: 'USER_NOT_FOUND'
|
||||||
};
|
};
|
||||||
|
|
||||||
const validationError: ApplicationErrorCode<'VALIDATION_ERROR', { field: string }> = {
|
const validationError: ApplicationErrorCode<MyErrorCodes, { field: string }> = {
|
||||||
code: 'VALIDATION_ERROR',
|
code: 'VALIDATION_ERROR',
|
||||||
details: { field: 'email' }
|
details: { field: 'email' }
|
||||||
};
|
};
|
||||||
|
|
||||||
const permissionError: ApplicationErrorCode<'PERMISSION_DENIED', { resource: string }> = {
|
const permissionError: ApplicationErrorCode<MyErrorCodes, { resource: string }> = {
|
||||||
code: 'PERMISSION_DENIED',
|
code: 'PERMISSION_DENIED',
|
||||||
details: { resource: 'admin-panel' }
|
details: { resource: 'admin-panel' }
|
||||||
};
|
};
|
||||||
|
|||||||
14
tsconfig.eslint.json
Normal file
14
tsconfig.eslint.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["apps/website/*"],
|
||||||
|
"@core/*": ["core/*"],
|
||||||
|
"@adapters/*": ["adapters/*"],
|
||||||
|
"@testing/*": ["adapters/testing/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["**/*"],
|
||||||
|
"exclude": ["node_modules", "dist", "**/dist/**", "**/.next/**"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user