Files
gridpilot.gg/core/racing/domain/value-objects/ImageUrl.test.ts
2026-01-16 19:46:49 +01:00

34 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { ImageUrl } from './ImageUrl';
describe('ImageUrl', () => {
it('should create valid url', () => {
const url = ImageUrl.create('https://example.com/image.jpg');
expect(url.toString()).toBe('https://example.com/image.jpg');
});
it('should throw on empty', () => {
expect(() => ImageUrl.create('')).toThrow('Image URL cannot be empty');
});
it('should throw on invalid url', () => {
expect(() => ImageUrl.create('not-a-url')).toThrow('Invalid image URL format');
});
it('should trim', () => {
const url = ImageUrl.create(' https://example.com ');
expect(url.toString()).toBe('https://example.com');
});
it('should equal same', () => {
const u1 = ImageUrl.create('https://example.com');
const u2 = ImageUrl.create('https://example.com');
expect(u1.equals(u2)).toBe(true);
});
it('should not equal different', () => {
const u1 = ImageUrl.create('https://example.com/1');
const u2 = ImageUrl.create('https://example.com/2');
expect(u1.equals(u2)).toBe(false);
});
});