60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { AdminDashboardViewDataBuilder } from './AdminDashboardViewDataBuilder';
|
|
import type { DashboardStatsResponseDTO } from '@/lib/types/generated/DashboardStatsResponseDTO';
|
|
|
|
describe('AdminDashboardViewDataBuilder', () => {
|
|
describe('happy paths', () => {
|
|
it('should transform DashboardStatsResponseDTO to AdminDashboardViewData correctly', () => {
|
|
const dashboardStats: DashboardStatsResponseDTO = {
|
|
totalUsers: 1000,
|
|
activeUsers: 800,
|
|
suspendedUsers: 50,
|
|
deletedUsers: 150,
|
|
systemAdmins: 5,
|
|
recentLogins: 120,
|
|
newUsersToday: 15,
|
|
};
|
|
|
|
const result = AdminDashboardViewDataBuilder.build(dashboardStats);
|
|
|
|
expect(result).toEqual({
|
|
stats: {
|
|
totalUsers: 1000,
|
|
activeUsers: 800,
|
|
suspendedUsers: 50,
|
|
deletedUsers: 150,
|
|
systemAdmins: 5,
|
|
recentLogins: 120,
|
|
newUsersToday: 15,
|
|
},
|
|
});
|
|
});
|
|
|
|
it('should handle zero values correctly', () => {
|
|
const dashboardStats: DashboardStatsResponseDTO = {
|
|
totalUsers: 0,
|
|
activeUsers: 0,
|
|
suspendedUsers: 0,
|
|
deletedUsers: 0,
|
|
systemAdmins: 0,
|
|
recentLogins: 0,
|
|
newUsersToday: 0,
|
|
};
|
|
|
|
const result = AdminDashboardViewDataBuilder.build(dashboardStats);
|
|
|
|
expect(result).toEqual({
|
|
stats: {
|
|
totalUsers: 0,
|
|
activeUsers: 0,
|
|
suspendedUsers: 0,
|
|
deletedUsers: 0,
|
|
systemAdmins: 0,
|
|
recentLogins: 0,
|
|
newUsersToday: 0,
|
|
},
|
|
});
|
|
});
|
|
});
|
|
});
|