45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { TrackImageUrl } from './TrackImageUrl';
|
|
|
|
describe('TrackImageUrl', () => {
|
|
it('should create track image url', () => {
|
|
const url = TrackImageUrl.create('http://example.com/image.jpg');
|
|
expect(url.toString()).toBe('http://example.com/image.jpg');
|
|
expect(url.props).toBe('http://example.com/image.jpg');
|
|
});
|
|
|
|
it('should allow undefined', () => {
|
|
const url = TrackImageUrl.create(undefined);
|
|
expect(url.toString()).toBeUndefined();
|
|
expect(url.props).toBeUndefined();
|
|
});
|
|
|
|
it('should throw for empty string', () => {
|
|
expect(() => TrackImageUrl.create('')).toThrow('Track image URL cannot be empty string');
|
|
expect(() => TrackImageUrl.create(' ')).toThrow('Track image URL cannot be empty string');
|
|
});
|
|
|
|
it('should equal same urls', () => {
|
|
const u1 = TrackImageUrl.create('http://example.com/image.jpg');
|
|
const u2 = TrackImageUrl.create('http://example.com/image.jpg');
|
|
expect(u1.equals(u2)).toBe(true);
|
|
});
|
|
|
|
it('should equal undefined', () => {
|
|
const u1 = TrackImageUrl.create(undefined);
|
|
const u2 = TrackImageUrl.create(undefined);
|
|
expect(u1.equals(u2)).toBe(true);
|
|
});
|
|
|
|
it('should not equal different urls', () => {
|
|
const u1 = TrackImageUrl.create('http://example.com/image1.jpg');
|
|
const u2 = TrackImageUrl.create('http://example.com/image2.jpg');
|
|
expect(u1.equals(u2)).toBe(false);
|
|
});
|
|
|
|
it('should not equal url and undefined', () => {
|
|
const u1 = TrackImageUrl.create('http://example.com/image.jpg');
|
|
const u2 = TrackImageUrl.create(undefined);
|
|
expect(u1.equals(u2)).toBe(false);
|
|
});
|
|
}); |