48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
|
import { TeamRatingDimensionKey } from './TeamRatingDimensionKey';
|
|
|
|
describe('TeamRatingDimensionKey', () => {
|
|
describe('create', () => {
|
|
it('should create valid dimension keys', () => {
|
|
expect(TeamRatingDimensionKey.create('driving').value).toBe('driving');
|
|
expect(TeamRatingDimensionKey.create('adminTrust').value).toBe('adminTrust');
|
|
});
|
|
|
|
it('should throw for invalid dimension key', () => {
|
|
expect(() => TeamRatingDimensionKey.create('invalid')).toThrow(RacingDomainValidationError);
|
|
expect(() => TeamRatingDimensionKey.create('driving ')).toThrow(RacingDomainValidationError);
|
|
expect(() => TeamRatingDimensionKey.create('')).toThrow(RacingDomainValidationError);
|
|
});
|
|
|
|
it('should throw for empty string', () => {
|
|
expect(() => TeamRatingDimensionKey.create('')).toThrow(RacingDomainValidationError);
|
|
});
|
|
|
|
it('should throw for whitespace', () => {
|
|
expect(() => TeamRatingDimensionKey.create(' ')).toThrow(RacingDomainValidationError);
|
|
});
|
|
|
|
it('should return true for same value', () => {
|
|
const key1 = TeamRatingDimensionKey.create('driving');
|
|
const key2 = TeamRatingDimensionKey.create('driving');
|
|
expect(key1.equals(key2)).toBe(true);
|
|
});
|
|
|
|
it('should return false for different values', () => {
|
|
const key1 = TeamRatingDimensionKey.create('driving');
|
|
const key2 = TeamRatingDimensionKey.create('adminTrust');
|
|
expect(key1.equals(key2)).toBe(false);
|
|
});
|
|
|
|
it('should expose props correctly', () => {
|
|
const key = TeamRatingDimensionKey.create('driving');
|
|
expect(key.props.value).toBe('driving');
|
|
});
|
|
|
|
it('should return string representation', () => {
|
|
const key = TeamRatingDimensionKey.create('driving');
|
|
expect(key.toString()).toBe('driving');
|
|
});
|
|
});
|
|
}); |