view models
This commit is contained in:
@@ -3,22 +3,19 @@ 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 } = {
|
||||
it('should create instance with success flag', () => {
|
||||
const dto: CompleteOnboardingOutputDTO = {
|
||||
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 } = {
|
||||
it('should expose isSuccessful as true when success is true', () => {
|
||||
const dto: CompleteOnboardingOutputDTO = {
|
||||
success: true,
|
||||
driverId: 'driver-123',
|
||||
};
|
||||
|
||||
const viewModel = new CompleteOnboardingViewModel(dto);
|
||||
@@ -26,31 +23,13 @@ describe('CompleteOnboardingViewModel', () => {
|
||||
expect(viewModel.isSuccessful).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for isSuccessful when success is false', () => {
|
||||
const dto: CompleteOnboardingOutputDTO & { driverId: string } = {
|
||||
it('should expose isSuccessful as false when success is false', () => {
|
||||
const dto: CompleteOnboardingOutputDTO = {
|
||||
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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user