Files
gridpilot.gg/apps/website/lib/view-models/AvatarViewModel.test.ts
2025-12-18 00:08:47 +01:00

53 lines
1.4 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { AvatarViewModel } from './AvatarViewModel';
describe('AvatarViewModel', () => {
it('should create instance with driverId and avatarUrl', () => {
const dto = {
driverId: 'driver-123',
avatarUrl: 'https://example.com/avatar.jpg',
};
const viewModel = new AvatarViewModel(dto);
expect(viewModel.driverId).toBe('driver-123');
expect(viewModel.avatarUrl).toBe('https://example.com/avatar.jpg');
});
it('should create instance without avatarUrl', () => {
const dto = {
driverId: 'driver-123',
};
const viewModel = new AvatarViewModel(dto);
expect(viewModel.driverId).toBe('driver-123');
expect(viewModel.avatarUrl).toBeUndefined();
});
it('should return true for hasAvatar when avatarUrl exists', () => {
const viewModel = new AvatarViewModel({
driverId: 'driver-123',
avatarUrl: 'https://example.com/avatar.jpg',
});
expect(viewModel.hasAvatar).toBe(true);
});
it('should return false for hasAvatar when avatarUrl is undefined', () => {
const viewModel = new AvatarViewModel({
driverId: 'driver-123',
});
expect(viewModel.hasAvatar).toBe(false);
});
it('should return false for hasAvatar when avatarUrl is empty string', () => {
const viewModel = new AvatarViewModel({
driverId: 'driver-123',
avatarUrl: '',
});
expect(viewModel.hasAvatar).toBe(false);
});
});