Files
gridpilot.gg/core/racing/domain/value-objects/LeagueTimezone.test.ts
2025-12-17 01:23:09 +01:00

37 lines
1.2 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { LeagueTimezone } from './LeagueTimezone';
describe('LeagueTimezone', () => {
it('should create valid timezone', () => {
const tz = LeagueTimezone.create('America/New_York');
expect(tz.id).toBe('America/New_York');
});
it('should trim whitespace', () => {
const tz = LeagueTimezone.create(' America/New_York ');
expect(tz.id).toBe('America/New_York');
});
it('should validate non-empty', () => {
expect(() => LeagueTimezone.create('')).toThrow('LeagueTimezone id must be a non-empty string');
expect(() => LeagueTimezone.create(' ')).toThrow('LeagueTimezone id must be a non-empty string');
});
it('should have props', () => {
const tz = LeagueTimezone.create('UTC');
expect(tz.props).toEqual({ id: 'UTC' });
});
it('should toString', () => {
const tz = LeagueTimezone.create('UTC');
expect(tz.toString()).toBe('UTC');
});
it('equals', () => {
const tz1 = LeagueTimezone.create('UTC');
const tz2 = LeagueTimezone.create('UTC');
const tz3 = LeagueTimezone.create('EST');
expect(tz1.equals(tz2)).toBe(true);
expect(tz1.equals(tz3)).toBe(false);
});
});