view models
This commit is contained in:
53
apps/website/lib/view-models/AvatarViewModel.test.ts
Normal file
53
apps/website/lib/view-models/AvatarViewModel.test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user