wip
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { AnalyticsEntityId } from '../../../../../packages/analytics/domain/value-objects/AnalyticsEntityId';
|
||||
|
||||
describe('AnalyticsEntityId', () => {
|
||||
it('creates a valid AnalyticsEntityId from a non-empty string', () => {
|
||||
const id = AnalyticsEntityId.create('entity_123');
|
||||
|
||||
expect(id.value).toBe('entity_123');
|
||||
});
|
||||
|
||||
it('trims whitespace from the raw value', () => {
|
||||
const id = AnalyticsEntityId.create(' entity_456 ');
|
||||
|
||||
expect(id.value).toBe('entity_456');
|
||||
});
|
||||
|
||||
it('throws for empty or whitespace-only strings', () => {
|
||||
expect(() => AnalyticsEntityId.create('')).toThrow(Error);
|
||||
expect(() => AnalyticsEntityId.create(' ')).toThrow(Error);
|
||||
});
|
||||
|
||||
it('compares equality based on underlying value', () => {
|
||||
const a = AnalyticsEntityId.create('entity_1');
|
||||
const b = AnalyticsEntityId.create('entity_1');
|
||||
const c = AnalyticsEntityId.create('entity_2');
|
||||
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(c)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { AnalyticsSessionId } from '../../../../../packages/analytics/domain/value-objects/AnalyticsSessionId';
|
||||
|
||||
describe('AnalyticsSessionId', () => {
|
||||
it('creates a valid AnalyticsSessionId from a non-empty string', () => {
|
||||
const id = AnalyticsSessionId.create('session_123');
|
||||
|
||||
expect(id.value).toBe('session_123');
|
||||
});
|
||||
|
||||
it('trims whitespace from the raw value', () => {
|
||||
const id = AnalyticsSessionId.create(' session_456 ');
|
||||
|
||||
expect(id.value).toBe('session_456');
|
||||
});
|
||||
|
||||
it('throws for empty or whitespace-only strings', () => {
|
||||
expect(() => AnalyticsSessionId.create('')).toThrow(Error);
|
||||
expect(() => AnalyticsSessionId.create(' ')).toThrow(Error);
|
||||
});
|
||||
|
||||
it('compares equality based on underlying value', () => {
|
||||
const a = AnalyticsSessionId.create('session_1');
|
||||
const b = AnalyticsSessionId.create('session_1');
|
||||
const c = AnalyticsSessionId.create('session_2');
|
||||
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(c)).toBe(false);
|
||||
});
|
||||
});
|
||||
29
tests/unit/analytics/domain/value-objects/PageViewId.test.ts
Normal file
29
tests/unit/analytics/domain/value-objects/PageViewId.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { PageViewId } from '../../../../../packages/analytics/domain/value-objects/PageViewId';
|
||||
|
||||
describe('PageViewId', () => {
|
||||
it('creates a valid PageViewId from a non-empty string', () => {
|
||||
const id = PageViewId.create('pv_123');
|
||||
|
||||
expect(id.value).toBe('pv_123');
|
||||
});
|
||||
|
||||
it('trims whitespace from the raw value', () => {
|
||||
const id = PageViewId.create(' pv_456 ');
|
||||
|
||||
expect(id.value).toBe('pv_456');
|
||||
});
|
||||
|
||||
it('throws for empty or whitespace-only strings', () => {
|
||||
expect(() => PageViewId.create('')).toThrow(Error);
|
||||
expect(() => PageViewId.create(' ')).toThrow(Error);
|
||||
});
|
||||
|
||||
it('compares equality based on underlying value', () => {
|
||||
const a = PageViewId.create('pv_1');
|
||||
const b = PageViewId.create('pv_1');
|
||||
const c = PageViewId.create('pv_2');
|
||||
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(c)).toBe(false);
|
||||
});
|
||||
});
|
||||
36
tests/unit/media/domain/value-objects/MediaUrl.test.ts
Normal file
36
tests/unit/media/domain/value-objects/MediaUrl.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { MediaUrl } from '../../../../../packages/media/domain/value-objects/MediaUrl';
|
||||
|
||||
describe('MediaUrl', () => {
|
||||
it('creates from valid http/https URLs', () => {
|
||||
expect(MediaUrl.create('http://example.com').value).toBe('http://example.com');
|
||||
expect(MediaUrl.create('https://example.com/path').value).toBe('https://example.com/path');
|
||||
});
|
||||
|
||||
it('creates from data URIs', () => {
|
||||
const url = 'data:image/jpeg;base64,AAA';
|
||||
expect(MediaUrl.create(url).value).toBe(url);
|
||||
});
|
||||
|
||||
it('creates from root-relative paths', () => {
|
||||
expect(MediaUrl.create('/images/avatar.png').value).toBe('/images/avatar.png');
|
||||
});
|
||||
|
||||
it('rejects empty or whitespace URLs', () => {
|
||||
expect(() => MediaUrl.create('')).toThrow();
|
||||
expect(() => MediaUrl.create(' ')).toThrow();
|
||||
});
|
||||
|
||||
it('rejects unsupported schemes', () => {
|
||||
expect(() => MediaUrl.create('ftp://example.com/file')).toThrow();
|
||||
expect(() => MediaUrl.create('mailto:user@example.com')).toThrow();
|
||||
});
|
||||
|
||||
it('implements value-based equality', () => {
|
||||
const a = MediaUrl.create('https://example.com/a.png');
|
||||
const b = MediaUrl.create('https://example.com/a.png');
|
||||
const c = MediaUrl.create('https://example.com/b.png');
|
||||
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(c)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
import { NotificationId } from '../../../../../packages/notifications/domain/value-objects/NotificationId';
|
||||
import { NotificationDomainError } from '../../../../../packages/notifications/domain/errors/NotificationDomainError';
|
||||
|
||||
describe('NotificationId', () => {
|
||||
it('creates a valid NotificationId from a non-empty string', () => {
|
||||
const id = NotificationId.create('noti_123');
|
||||
|
||||
expect(id.value).toBe('noti_123');
|
||||
});
|
||||
|
||||
it('trims whitespace from the raw value', () => {
|
||||
const id = NotificationId.create(' noti_456 ');
|
||||
|
||||
expect(id.value).toBe('noti_456');
|
||||
});
|
||||
|
||||
it('throws NotificationDomainError for empty string', () => {
|
||||
expect(() => NotificationId.create('')).toThrow(NotificationDomainError);
|
||||
expect(() => NotificationId.create(' ')).toThrow(NotificationDomainError);
|
||||
|
||||
try {
|
||||
NotificationId.create(' ');
|
||||
} catch (error) {
|
||||
if (error instanceof NotificationDomainError) {
|
||||
expect(error.kind).toBe('validation');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('compares equality based on underlying value', () => {
|
||||
const a = NotificationId.create('noti_1');
|
||||
const b = NotificationId.create('noti_1');
|
||||
const c = NotificationId.create('noti_2');
|
||||
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(c)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
import { QuietHours } from '../../../../../packages/notifications/domain/value-objects/QuietHours';
|
||||
|
||||
describe('QuietHours', () => {
|
||||
it('creates a valid normal-range window', () => {
|
||||
const qh = QuietHours.create(9, 17);
|
||||
expect(qh.props.startHour).toBe(9);
|
||||
expect(qh.props.endHour).toBe(17);
|
||||
});
|
||||
|
||||
it('creates a valid overnight window', () => {
|
||||
const qh = QuietHours.create(22, 7);
|
||||
expect(qh.props.startHour).toBe(22);
|
||||
expect(qh.props.endHour).toBe(7);
|
||||
});
|
||||
|
||||
it('throws when hours are out of range', () => {
|
||||
expect(() => QuietHours.create(-1, 10)).toThrow();
|
||||
expect(() => QuietHours.create(0, 24)).toThrow();
|
||||
});
|
||||
|
||||
it('throws when start and end are equal', () => {
|
||||
expect(() => QuietHours.create(10, 10)).toThrow();
|
||||
});
|
||||
|
||||
it('detects containment for normal range', () => {
|
||||
const qh = QuietHours.create(9, 17);
|
||||
expect(qh.containsHour(8)).toBe(false);
|
||||
expect(qh.containsHour(9)).toBe(true);
|
||||
expect(qh.containsHour(12)).toBe(true);
|
||||
expect(qh.containsHour(17)).toBe(false);
|
||||
});
|
||||
|
||||
it('detects containment for overnight range', () => {
|
||||
const qh = QuietHours.create(22, 7);
|
||||
expect(qh.containsHour(21)).toBe(false);
|
||||
expect(qh.containsHour(22)).toBe(true);
|
||||
expect(qh.containsHour(23)).toBe(true);
|
||||
expect(qh.containsHour(0)).toBe(true);
|
||||
expect(qh.containsHour(6)).toBe(true);
|
||||
expect(qh.containsHour(7)).toBe(false);
|
||||
});
|
||||
|
||||
it('implements value-based equality', () => {
|
||||
const a = QuietHours.create(22, 7);
|
||||
const b = QuietHours.create(22, 7);
|
||||
const c = QuietHours.create(9, 17);
|
||||
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(c)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,7 @@ import type { IResultRepository } from '@gridpilot/racing/domain/repositories/IR
|
||||
import type { ILeagueMembershipRepository } from '@gridpilot/racing/domain/repositories/ILeagueMembershipRepository';
|
||||
import type { LeagueMembership } from '@gridpilot/racing/domain/entities/LeagueMembership';
|
||||
import type { DriverRatingProvider } from '@gridpilot/racing/application/ports/DriverRatingProvider';
|
||||
import type { IImageService } from '@gridpilot/racing/domain/services/IImageService';
|
||||
import type { IImageServicePort } from '@gridpilot/racing/application/ports/IImageServicePort';
|
||||
import type {
|
||||
IRaceDetailPresenter,
|
||||
RaceDetailViewModel,
|
||||
@@ -336,7 +336,7 @@ class TestDriverRatingProvider implements DriverRatingProvider {
|
||||
}
|
||||
}
|
||||
|
||||
class TestImageService implements IImageService {
|
||||
class TestImageService implements IImageServicePort {
|
||||
getDriverAvatar(driverId: string): string {
|
||||
return `avatar-${driverId}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user