99 lines
3.9 KiB
TypeScript
99 lines
3.9 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { mediaConfig, type MediaConfig } from './mediaConfig';
|
|
|
|
describe('mediaConfig', () => {
|
|
describe('avatars', () => {
|
|
it('should have a default fallback path', () => {
|
|
expect(mediaConfig.avatars.defaultFallback).toBe('/images/avatars/neutral-default-avatar.jpeg');
|
|
});
|
|
|
|
it('should have all avatar type paths', () => {
|
|
expect(mediaConfig.avatars.paths).toHaveProperty('male');
|
|
expect(mediaConfig.avatars.paths).toHaveProperty('female');
|
|
expect(mediaConfig.avatars.paths).toHaveProperty('neutral');
|
|
});
|
|
|
|
it('should have correct male avatar path', () => {
|
|
expect(mediaConfig.avatars.paths.male).toBe('/images/avatars/male-default-avatar.jpg');
|
|
});
|
|
|
|
it('should have correct female avatar path', () => {
|
|
expect(mediaConfig.avatars.paths.female).toBe('/images/avatars/female-default-avatar.jpeg');
|
|
});
|
|
|
|
it('should have correct neutral avatar path', () => {
|
|
expect(mediaConfig.avatars.paths.neutral).toBe('/images/avatars/neutral-default-avatar.jpeg');
|
|
});
|
|
});
|
|
|
|
describe('api', () => {
|
|
it('should have avatar function that returns correct path', () => {
|
|
const result = mediaConfig.api.avatar('driver-123');
|
|
expect(result).toBe('/media/avatar/driver-123');
|
|
});
|
|
|
|
it('should have teamLogo function that returns correct path', () => {
|
|
const result = mediaConfig.api.teamLogo('team-456');
|
|
expect(result).toBe('/media/teams/team-456/logo');
|
|
});
|
|
|
|
it('should have trackImage function that returns correct path', () => {
|
|
const result = mediaConfig.api.trackImage('track-789');
|
|
expect(result).toBe('/media/tracks/track-789/image');
|
|
});
|
|
|
|
it('should have sponsorLogo function that returns correct path', () => {
|
|
const result = mediaConfig.api.sponsorLogo('sponsor-abc');
|
|
expect(result).toBe('/media/sponsors/sponsor-abc/logo');
|
|
});
|
|
|
|
it('should have categoryIcon function that returns correct path', () => {
|
|
const result = mediaConfig.api.categoryIcon('category-xyz');
|
|
expect(result).toBe('/media/categories/category-xyz/icon');
|
|
});
|
|
|
|
it('should handle special characters in IDs', () => {
|
|
const result = mediaConfig.api.avatar('driver-with-special_chars.123');
|
|
expect(result).toBe('/media/avatar/driver-with-special_chars.123');
|
|
});
|
|
});
|
|
|
|
describe('structure', () => {
|
|
it('should match expected MediaConfig interface', () => {
|
|
const config: MediaConfig = mediaConfig;
|
|
|
|
expect(config).toHaveProperty('avatars');
|
|
expect(config).toHaveProperty('api');
|
|
|
|
expect(typeof config.avatars.defaultFallback).toBe('string');
|
|
expect(typeof config.avatars.paths).toBe('object');
|
|
expect(typeof config.api.avatar).toBe('function');
|
|
expect(typeof config.api.teamLogo).toBe('function');
|
|
expect(typeof config.api.trackImage).toBe('function');
|
|
expect(typeof config.api.sponsorLogo).toBe('function');
|
|
expect(typeof config.api.categoryIcon).toBe('function');
|
|
});
|
|
|
|
it('should be immutable (as const)', () => {
|
|
// The config is declared as 'as const', so it should be readonly
|
|
// This test verifies the type is correct
|
|
const config: MediaConfig = mediaConfig;
|
|
expect(config).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('consistency', () => {
|
|
it('should use consistent paths for avatars', () => {
|
|
// Default fallback should match neutral path
|
|
expect(mediaConfig.avatars.defaultFallback).toBe(mediaConfig.avatars.paths.neutral);
|
|
});
|
|
|
|
it('should all start with /media/ prefix', () => {
|
|
expect(mediaConfig.api.avatar('test')).toMatch(/^\/media\//);
|
|
expect(mediaConfig.api.teamLogo('test')).toMatch(/^\/media\//);
|
|
expect(mediaConfig.api.trackImage('test')).toMatch(/^\/media\//);
|
|
expect(mediaConfig.api.sponsorLogo('test')).toMatch(/^\/media\//);
|
|
expect(mediaConfig.api.categoryIcon('test')).toMatch(/^\/media\//);
|
|
});
|
|
});
|
|
}); |