import { faker } from '@faker-js/faker/locale/en_US';
import { PerformanceReviewUserWithStatsPaginatedSC } from '../../../../src/api/modules/performanceReviews/presentation/serializationClasses/performanceReviewUserWithStatsPaginatedSC';
import { fakePositiveInteger } from '../../../common/common';
import { addStatsToPerformanceReviewUser, checkPerformanceReviewUserWithStatsSerialized, generateRandomPerformanceReviewUser } from '../common';

describe('PerformanceReviewUserWithStatsPaginatedSC', () => {
    it('should serialize review users with stats', () => {
        const reviewUsersCount = faker.number.int({ max: 20, min: 10 });
        const reviewUsers = Array(reviewUsersCount)
            .fill(1)
            .map(() => addStatsToPerformanceReviewUser(generateRandomPerformanceReviewUser(fakePositiveInteger())));
        const reviewUsersSerialized = new PerformanceReviewUserWithStatsPaginatedSC().serializePaginatedList({
            count: reviewUsersCount,
            limit: 10,
            offset: 0,
            rows: reviewUsers,
        });

        expect(reviewUsersSerialized.items).toHaveLength(reviewUsers.length);

        reviewUsersSerialized.items.forEach((reviewUserDTO, index) => {
            checkPerformanceReviewUserWithStatsSerialized(reviewUsers[index], reviewUserDTO);
        });
    });
});
