import { faker } from '@faker-js/faker/locale/en_US';
import { PerformanceReviewTargetUserPaginatedSC } from '../../../../src/api/modules/performanceReviews/presentation/serializationClasses/performanceReviewTargetUserPaginatedSC';
import { fakePositiveInteger } from '../../../common/common';
import { checkPerformanceReviewTargetUserSerialized, generateRandomPerformanceReviewTargetUser } from '../common';

describe('PerformanceReviewTargetUserPaginatedSC', () => {
    it('should serialize target users', () => {
        const targetUsersCount = faker.number.int({ max: 20, min: 10 });
        const targetUsers = Array(targetUsersCount)
            .fill(1)
            .map(() => generateRandomPerformanceReviewTargetUser(fakePositiveInteger()));
        const targetUsersSerialized = new PerformanceReviewTargetUserPaginatedSC().serializePaginatedList({
            count: targetUsersCount,
            limit: 10,
            offset: 0,
            rows: targetUsers,
        });

        expect(targetUsersSerialized.items).toHaveLength(targetUsers.length);

        targetUsersSerialized.items.forEach((reviewUserDTO, index) => {
            checkPerformanceReviewTargetUserSerialized(targetUsers[index], reviewUserDTO);
        });
    });
});
