add tests to core
This commit is contained in:
62
core/identity/domain/entities/Achievement.test.ts
Normal file
62
core/identity/domain/entities/Achievement.test.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { Achievement } from '@core/identity/domain/entities/Achievement';
|
||||
|
||||
describe('Achievement', () => {
|
||||
const baseProps = () => ({
|
||||
id: 'ach-1',
|
||||
name: 'First Win',
|
||||
description: 'Win your first race',
|
||||
category: 'driver' as const,
|
||||
rarity: 'common' as const,
|
||||
points: 10,
|
||||
requirements: [{ type: 'wins' as const, value: 1, operator: '>=' as const }],
|
||||
isSecret: false,
|
||||
});
|
||||
|
||||
it('creates an Achievement with default iconUrl', () => {
|
||||
const a = Achievement.create(baseProps());
|
||||
|
||||
expect(a.id).toBe('ach-1');
|
||||
expect(a.iconUrl).toBe('');
|
||||
expect(a.createdAt).toBeInstanceOf(Date);
|
||||
});
|
||||
|
||||
it('throws if id is missing', () => {
|
||||
expect(() => Achievement.create({ ...baseProps(), id: '' })).toThrow(Error);
|
||||
expect(() => Achievement.create({ ...baseProps(), id: ' ' })).toThrow(Error);
|
||||
});
|
||||
|
||||
it('throws if name is missing', () => {
|
||||
expect(() => Achievement.create({ ...baseProps(), name: '' })).toThrow(Error);
|
||||
expect(() => Achievement.create({ ...baseProps(), name: ' ' })).toThrow(Error);
|
||||
});
|
||||
|
||||
it('throws if requirements is empty', () => {
|
||||
expect(() => Achievement.create({ ...baseProps(), requirements: [] })).toThrow(Error);
|
||||
});
|
||||
|
||||
it('checkRequirements evaluates all requirements', () => {
|
||||
const a = Achievement.create({
|
||||
...baseProps(),
|
||||
requirements: [
|
||||
{ type: 'wins', value: 2, operator: '>=' },
|
||||
{ type: 'podiums', value: 1, operator: '>=' },
|
||||
],
|
||||
});
|
||||
|
||||
expect(a.checkRequirements({ wins: 2, podiums: 1 })).toBe(true);
|
||||
expect(a.checkRequirements({ wins: 1, podiums: 1 })).toBe(false);
|
||||
expect(a.checkRequirements({ wins: 2 })).toBe(false);
|
||||
});
|
||||
|
||||
it('getRarityColor returns the configured color', () => {
|
||||
expect(Achievement.create({ ...baseProps(), rarity: 'common' }).getRarityColor()).toBe('#9CA3AF');
|
||||
expect(Achievement.create({ ...baseProps(), rarity: 'legendary' }).getRarityColor()).toBe('#F59E0B');
|
||||
});
|
||||
|
||||
it('hides name/description when secret', () => {
|
||||
const a = Achievement.create({ ...baseProps(), isSecret: true });
|
||||
|
||||
expect(a.getDisplayName()).toBe('???');
|
||||
expect(a.getDisplayDescription()).toContain('secret');
|
||||
});
|
||||
});
|
||||
7
core/identity/domain/entities/SponsorAccount.test.ts
Normal file
7
core/identity/domain/entities/SponsorAccount.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as mod from '@core/identity/domain/entities/SponsorAccount';
|
||||
|
||||
describe('identity/domain/entities/SponsorAccount.ts', () => {
|
||||
it('imports', () => {
|
||||
expect(mod).toBeTruthy();
|
||||
});
|
||||
});
|
||||
7
core/identity/domain/entities/User.test.ts
Normal file
7
core/identity/domain/entities/User.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as mod from '@core/identity/domain/entities/User';
|
||||
|
||||
describe('identity/domain/entities/User.ts', () => {
|
||||
it('imports', () => {
|
||||
expect(mod).toBeTruthy();
|
||||
});
|
||||
});
|
||||
7
core/identity/domain/entities/UserAchievement.test.ts
Normal file
7
core/identity/domain/entities/UserAchievement.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as mod from '@core/identity/domain/entities/UserAchievement';
|
||||
|
||||
describe('identity/domain/entities/UserAchievement.ts', () => {
|
||||
it('imports', () => {
|
||||
expect(mod).toBeTruthy();
|
||||
});
|
||||
});
|
||||
7
core/identity/domain/value-objects/EmailAddress.test.ts
Normal file
7
core/identity/domain/value-objects/EmailAddress.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as mod from '@core/identity/domain/value-objects/EmailAddress';
|
||||
|
||||
describe('identity/domain/value-objects/EmailAddress.ts', () => {
|
||||
it('imports', () => {
|
||||
expect(mod).toBeTruthy();
|
||||
});
|
||||
});
|
||||
7
core/identity/domain/value-objects/PasswordHash.test.ts
Normal file
7
core/identity/domain/value-objects/PasswordHash.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as mod from '@core/identity/domain/value-objects/PasswordHash';
|
||||
|
||||
describe('identity/domain/value-objects/PasswordHash.ts', () => {
|
||||
it('imports', () => {
|
||||
expect(mod).toBeTruthy();
|
||||
});
|
||||
});
|
||||
7
core/identity/domain/value-objects/UserId.test.ts
Normal file
7
core/identity/domain/value-objects/UserId.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as mod from '@core/identity/domain/value-objects/UserId';
|
||||
|
||||
describe('identity/domain/value-objects/UserId.ts', () => {
|
||||
it('imports', () => {
|
||||
expect(mod).toBeTruthy();
|
||||
});
|
||||
});
|
||||
7
core/identity/domain/value-objects/UserRating.test.ts
Normal file
7
core/identity/domain/value-objects/UserRating.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as mod from '@core/identity/domain/value-objects/UserRating';
|
||||
|
||||
describe('identity/domain/value-objects/UserRating.ts', () => {
|
||||
it('imports', () => {
|
||||
expect(mod).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user