247 lines
7.1 KiB
TypeScript
247 lines
7.1 KiB
TypeScript
import { GetDashboardDataOutputDTO } from './GetDashboardDataOutputDTO';
|
|
|
|
describe('GetDashboardDataOutputDTO', () => {
|
|
describe('TDD - Test First', () => {
|
|
it('should create valid DTO with all fields', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 100;
|
|
dto.activeUsers = 50;
|
|
dto.totalRaces = 20;
|
|
dto.totalLeagues = 5;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(100);
|
|
expect(dto.activeUsers).toBe(50);
|
|
expect(dto.totalRaces).toBe(20);
|
|
expect(dto.totalLeagues).toBe(5);
|
|
});
|
|
|
|
it('should handle zero values', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 0;
|
|
dto.activeUsers = 0;
|
|
dto.totalRaces = 0;
|
|
dto.totalLeagues = 0;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(0);
|
|
expect(dto.activeUsers).toBe(0);
|
|
expect(dto.totalRaces).toBe(0);
|
|
expect(dto.totalLeagues).toBe(0);
|
|
});
|
|
|
|
it('should handle large numbers', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 1000000;
|
|
dto.activeUsers = 500000;
|
|
dto.totalRaces = 100000;
|
|
dto.totalLeagues = 10000;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(1000000);
|
|
expect(dto.activeUsers).toBe(500000);
|
|
expect(dto.totalRaces).toBe(100000);
|
|
expect(dto.totalLeagues).toBe(10000);
|
|
});
|
|
|
|
it('should handle single digit values', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 1;
|
|
dto.activeUsers = 1;
|
|
dto.totalRaces = 1;
|
|
dto.totalLeagues = 1;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(1);
|
|
expect(dto.activeUsers).toBe(1);
|
|
expect(dto.totalRaces).toBe(1);
|
|
expect(dto.totalLeagues).toBe(1);
|
|
});
|
|
|
|
it('should handle active users greater than total users', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 100;
|
|
dto.activeUsers = 150;
|
|
dto.totalRaces = 20;
|
|
dto.totalLeagues = 5;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(100);
|
|
expect(dto.activeUsers).toBe(150);
|
|
});
|
|
|
|
it('should handle zero active users', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 100;
|
|
dto.activeUsers = 0;
|
|
dto.totalRaces = 20;
|
|
dto.totalLeagues = 5;
|
|
|
|
// Assert
|
|
expect(dto.activeUsers).toBe(0);
|
|
});
|
|
|
|
it('should handle zero total users', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 0;
|
|
dto.activeUsers = 0;
|
|
dto.totalRaces = 20;
|
|
dto.totalLeagues = 5;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(0);
|
|
});
|
|
|
|
it('should handle zero races', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 100;
|
|
dto.activeUsers = 50;
|
|
dto.totalRaces = 0;
|
|
dto.totalLeagues = 5;
|
|
|
|
// Assert
|
|
expect(dto.totalRaces).toBe(0);
|
|
});
|
|
|
|
it('should handle zero leagues', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 100;
|
|
dto.activeUsers = 50;
|
|
dto.totalRaces = 20;
|
|
dto.totalLeagues = 0;
|
|
|
|
// Assert
|
|
expect(dto.totalLeagues).toBe(0);
|
|
});
|
|
|
|
it('should handle very large numbers', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 999999999;
|
|
dto.activeUsers = 888888888;
|
|
dto.totalRaces = 777777777;
|
|
dto.totalLeagues = 666666666;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(999999999);
|
|
expect(dto.activeUsers).toBe(888888888);
|
|
expect(dto.totalRaces).toBe(777777777);
|
|
expect(dto.totalLeagues).toBe(666666666);
|
|
});
|
|
|
|
it('should handle decimal numbers', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 100.5;
|
|
dto.activeUsers = 50.7;
|
|
dto.totalRaces = 20.3;
|
|
dto.totalLeagues = 5.9;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(100.5);
|
|
expect(dto.activeUsers).toBe(50.7);
|
|
expect(dto.totalRaces).toBe(20.3);
|
|
expect(dto.totalLeagues).toBe(5.9);
|
|
});
|
|
|
|
it('should handle negative numbers', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = -100;
|
|
dto.activeUsers = -50;
|
|
dto.totalRaces = -20;
|
|
dto.totalLeagues = -5;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(-100);
|
|
expect(dto.activeUsers).toBe(-50);
|
|
expect(dto.totalRaces).toBe(-20);
|
|
expect(dto.totalLeagues).toBe(-5);
|
|
});
|
|
|
|
it('should handle scientific notation', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = 1e6;
|
|
dto.activeUsers = 5e5;
|
|
dto.totalRaces = 2e4;
|
|
dto.totalLeagues = 5e3;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(1000000);
|
|
expect(dto.activeUsers).toBe(500000);
|
|
expect(dto.totalRaces).toBe(20000);
|
|
expect(dto.totalLeagues).toBe(5000);
|
|
});
|
|
|
|
it('should handle maximum safe integer', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = Number.MAX_SAFE_INTEGER;
|
|
dto.activeUsers = Number.MAX_SAFE_INTEGER;
|
|
dto.totalRaces = Number.MAX_SAFE_INTEGER;
|
|
dto.totalLeagues = Number.MAX_SAFE_INTEGER;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(Number.MAX_SAFE_INTEGER);
|
|
expect(dto.activeUsers).toBe(Number.MAX_SAFE_INTEGER);
|
|
expect(dto.totalRaces).toBe(Number.MAX_SAFE_INTEGER);
|
|
expect(dto.totalLeagues).toBe(Number.MAX_SAFE_INTEGER);
|
|
});
|
|
|
|
it('should handle minimum safe integer', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = Number.MIN_SAFE_INTEGER;
|
|
dto.activeUsers = Number.MIN_SAFE_INTEGER;
|
|
dto.totalRaces = Number.MIN_SAFE_INTEGER;
|
|
dto.totalLeagues = Number.MIN_SAFE_INTEGER;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(Number.MIN_SAFE_INTEGER);
|
|
expect(dto.activeUsers).toBe(Number.MIN_SAFE_INTEGER);
|
|
expect(dto.totalRaces).toBe(Number.MIN_SAFE_INTEGER);
|
|
expect(dto.totalLeagues).toBe(Number.MIN_SAFE_INTEGER);
|
|
});
|
|
|
|
it('should handle Infinity', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = Infinity;
|
|
dto.activeUsers = Infinity;
|
|
dto.totalRaces = Infinity;
|
|
dto.totalLeagues = Infinity;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBe(Infinity);
|
|
expect(dto.activeUsers).toBe(Infinity);
|
|
expect(dto.totalRaces).toBe(Infinity);
|
|
expect(dto.totalLeagues).toBe(Infinity);
|
|
});
|
|
|
|
it('should handle NaN', () => {
|
|
// Arrange & Act
|
|
const dto = new GetDashboardDataOutputDTO();
|
|
dto.totalUsers = NaN;
|
|
dto.activeUsers = NaN;
|
|
dto.totalRaces = NaN;
|
|
dto.totalLeagues = NaN;
|
|
|
|
// Assert
|
|
expect(dto.totalUsers).toBeNaN();
|
|
expect(dto.activeUsers).toBeNaN();
|
|
expect(dto.totalRaces).toBeNaN();
|
|
expect(dto.totalLeagues).toBeNaN();
|
|
});
|
|
});
|
|
});
|