Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import { ProfileTestContext } from '../ProfileTestContext';
|
|
import { GetDriverLiveriesUseCase } from '../../../../core/racing/application/use-cases/GetDriverLiveriesUseCase';
|
|
import { DriverLivery } from '../../../../core/racing/domain/entities/DriverLivery';
|
|
|
|
describe('GetDriverLiveriesUseCase', () => {
|
|
let context: ProfileTestContext;
|
|
let useCase: GetDriverLiveriesUseCase;
|
|
|
|
beforeEach(async () => {
|
|
context = new ProfileTestContext();
|
|
useCase = new GetDriverLiveriesUseCase(context.liveryRepository, context.logger);
|
|
await context.clear();
|
|
});
|
|
|
|
it('should retrieve driver liveries', async () => {
|
|
// Given: A driver has liveries
|
|
const driverId = 'd3';
|
|
const livery = DriverLivery.create({
|
|
id: 'l1',
|
|
driverId,
|
|
gameId: 'iracing',
|
|
carId: 'porsche_911_gt3_r',
|
|
uploadedImageUrl: 'https://example.com/livery.png'
|
|
});
|
|
await context.liveryRepository.createDriverLivery(livery);
|
|
|
|
// When: GetDriverLiveriesUseCase.execute() is called
|
|
const result = await useCase.execute({ driverId });
|
|
|
|
// Then: It should return the liveries
|
|
expect(result.isOk()).toBe(true);
|
|
const liveries = result.unwrap();
|
|
expect(liveries).toHaveLength(1);
|
|
expect(liveries[0].id).toBe('l1');
|
|
});
|
|
});
|