48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import type { DashboardStatsResponseDto } from '../../types/generated/DashboardStatsResponseDTO';
|
|
import type { AdminDashboardViewData } from '../../view-data/AdminDashboardViewData';
|
|
import { AdminDashboardViewDataBuilder } from './AdminDashboardViewDataBuilder';
|
|
|
|
describe('AdminDashboardViewDataBuilder', () => {
|
|
it('should transform DashboardStatsResponseDto to AdminDashboardViewData correctly', () => {
|
|
const apiDto: DashboardStatsResponseDto = {
|
|
totalUsers: 1000,
|
|
activeUsers: 800,
|
|
suspendedUsers: 50,
|
|
deletedUsers: 150,
|
|
systemAdmins: 5,
|
|
recentLogins: 200,
|
|
newUsersToday: 10,
|
|
};
|
|
|
|
const result: AdminDashboardViewData = AdminDashboardViewDataBuilder.build(apiDto);
|
|
|
|
expect(result.stats).toEqual({
|
|
totalUsers: 1000,
|
|
activeUsers: 800,
|
|
suspendedUsers: 50,
|
|
deletedUsers: 150,
|
|
systemAdmins: 5,
|
|
recentLogins: 200,
|
|
newUsersToday: 10,
|
|
});
|
|
});
|
|
|
|
it('should not modify the input DTO', () => {
|
|
const apiDto: DashboardStatsResponseDto = {
|
|
totalUsers: 1000,
|
|
activeUsers: 800,
|
|
suspendedUsers: 50,
|
|
deletedUsers: 150,
|
|
systemAdmins: 5,
|
|
recentLogins: 200,
|
|
newUsersToday: 10,
|
|
};
|
|
|
|
const originalDto = { ...apiDto };
|
|
AdminDashboardViewDataBuilder.build(apiDto);
|
|
|
|
expect(apiDto).toEqual(originalDto);
|
|
});
|
|
});
|