refactor
This commit is contained in:
141
core/racing/domain/value-objects/DecalOverride.test.ts
Normal file
141
core/racing/domain/value-objects/DecalOverride.test.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { DecalOverride } from './DecalOverride';
|
||||
|
||||
describe('DecalOverride', () => {
|
||||
it('should create a decal override', () => {
|
||||
const override = DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
});
|
||||
expect(override.props).toEqual({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw on empty leagueId', () => {
|
||||
expect(() =>
|
||||
DecalOverride.create({
|
||||
leagueId: '',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
})
|
||||
).toThrow('DecalOverride leagueId is required');
|
||||
});
|
||||
|
||||
it('should throw on empty seasonId', () => {
|
||||
expect(() =>
|
||||
DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: '',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
})
|
||||
).toThrow('DecalOverride seasonId is required');
|
||||
});
|
||||
|
||||
it('should throw on empty decalId', () => {
|
||||
expect(() =>
|
||||
DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: '',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
})
|
||||
).toThrow('DecalOverride decalId is required');
|
||||
});
|
||||
|
||||
it('should throw on newX less than 0', () => {
|
||||
expect(() =>
|
||||
DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: -0.1,
|
||||
newY: 0.3,
|
||||
})
|
||||
).toThrow('DecalOverride newX must be between 0 and 1');
|
||||
});
|
||||
|
||||
it('should throw on newX greater than 1', () => {
|
||||
expect(() =>
|
||||
DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 1.1,
|
||||
newY: 0.3,
|
||||
})
|
||||
).toThrow('DecalOverride newX must be between 0 and 1');
|
||||
});
|
||||
|
||||
it('should throw on newY less than 0', () => {
|
||||
expect(() =>
|
||||
DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: -0.1,
|
||||
})
|
||||
).toThrow('DecalOverride newY must be between 0 and 1');
|
||||
});
|
||||
|
||||
it('should throw on newY greater than 1', () => {
|
||||
expect(() =>
|
||||
DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 1.1,
|
||||
})
|
||||
).toThrow('DecalOverride newY must be between 0 and 1');
|
||||
});
|
||||
|
||||
it('should equal same override', () => {
|
||||
const o1 = DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
});
|
||||
const o2 = DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
});
|
||||
expect(o1.equals(o2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should not equal different override', () => {
|
||||
const o1 = DecalOverride.create({
|
||||
leagueId: 'league1',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
});
|
||||
const o2 = DecalOverride.create({
|
||||
leagueId: 'league2',
|
||||
seasonId: 'season1',
|
||||
decalId: 'decal1',
|
||||
newX: 0.5,
|
||||
newY: 0.3,
|
||||
});
|
||||
expect(o1.equals(o2)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user