core tests
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { DashboardPresenter } from './DashboardPresenter';
|
||||
import { DashboardDTO } from '../dto/DashboardDTO';
|
||||
|
||||
describe('DashboardPresenter', () => {
|
||||
it('should return the data as is (identity transformation)', () => {
|
||||
const presenter = new DashboardPresenter();
|
||||
const mockData: DashboardDTO = {
|
||||
driver: {
|
||||
id: '1',
|
||||
name: 'John Doe',
|
||||
avatar: 'http://example.com/avatar.png',
|
||||
},
|
||||
statistics: {
|
||||
rating: 1500,
|
||||
rank: 10,
|
||||
starts: 50,
|
||||
wins: 5,
|
||||
podiums: 15,
|
||||
leagues: 3,
|
||||
},
|
||||
upcomingRaces: [],
|
||||
championshipStandings: [],
|
||||
recentActivity: [],
|
||||
};
|
||||
|
||||
const result = presenter.present(mockData);
|
||||
|
||||
expect(result).toBe(mockData);
|
||||
});
|
||||
});
|
||||
20
core/dashboard/domain/errors/DriverNotFoundError.test.ts
Normal file
20
core/dashboard/domain/errors/DriverNotFoundError.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { DriverNotFoundError } from './DriverNotFoundError';
|
||||
|
||||
describe('DriverNotFoundError', () => {
|
||||
it('should create an error with the correct message and properties', () => {
|
||||
const driverId = 'driver-123';
|
||||
const error = new DriverNotFoundError(driverId);
|
||||
|
||||
expect(error.message).toBe(`Driver with ID "${driverId}" not found`);
|
||||
expect(error.name).toBe('DriverNotFoundError');
|
||||
expect(error.type).toBe('domain');
|
||||
expect(error.context).toBe('dashboard');
|
||||
expect(error.kind).toBe('not_found');
|
||||
});
|
||||
|
||||
it('should be an instance of Error', () => {
|
||||
const error = new DriverNotFoundError('123');
|
||||
expect(error).toBeInstanceOf(Error);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user