56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { CompleteOnboardingViewModel } from './CompleteOnboardingViewModel';
|
|
import type { CompleteOnboardingOutputDTO } from '../types/generated/CompleteOnboardingOutputDTO';
|
|
|
|
describe('CompleteOnboardingViewModel', () => {
|
|
it('should create instance with success and driverId', () => {
|
|
const dto: CompleteOnboardingOutputDTO & { driverId: string } = {
|
|
success: true,
|
|
driverId: 'driver-123',
|
|
};
|
|
|
|
const viewModel = new CompleteOnboardingViewModel(dto);
|
|
|
|
expect(viewModel.success).toBe(true);
|
|
expect(viewModel.driverId).toBe('driver-123');
|
|
});
|
|
|
|
it('should return true for isSuccessful when success is true', () => {
|
|
const dto: CompleteOnboardingOutputDTO & { driverId: string } = {
|
|
success: true,
|
|
driverId: 'driver-123',
|
|
};
|
|
|
|
const viewModel = new CompleteOnboardingViewModel(dto);
|
|
|
|
expect(viewModel.isSuccessful).toBe(true);
|
|
});
|
|
|
|
it('should return false for isSuccessful when success is false', () => {
|
|
const dto: CompleteOnboardingOutputDTO & { driverId: string } = {
|
|
success: false,
|
|
driverId: 'driver-123',
|
|
};
|
|
|
|
const viewModel = new CompleteOnboardingViewModel(dto);
|
|
|
|
expect(viewModel.isSuccessful).toBe(false);
|
|
});
|
|
|
|
it('should preserve driverId regardless of success status', () => {
|
|
const successDto: CompleteOnboardingOutputDTO & { driverId: string } = {
|
|
success: true,
|
|
driverId: 'driver-success',
|
|
};
|
|
const failDto: CompleteOnboardingOutputDTO & { driverId: string } = {
|
|
success: false,
|
|
driverId: 'driver-fail',
|
|
};
|
|
|
|
const successViewModel = new CompleteOnboardingViewModel(successDto);
|
|
const failViewModel = new CompleteOnboardingViewModel(failDto);
|
|
|
|
expect(successViewModel.driverId).toBe('driver-success');
|
|
expect(failViewModel.driverId).toBe('driver-fail');
|
|
});
|
|
}); |