import { faker } from '@faker-js/faker/locale/en_US';
import { PerformanceReviewReviewedPaginatedSC } from '../../../../src/api/modules/performanceReviews/presentation/serializationClasses/performanceReviewReviewedPaginatedSC';
import { User } from '../../../../src/api/modules/users/business/models/user';
import { fakePositiveInteger } from '../../../common/common';
import { checkPerformanceReviewReviewedSerialized, generatePerformanceReviewReviewer, generateRandomPerformanceReviewUser } from '../common';

describe('PerformanceReviewReviewedPaginatedSC', () => {
    it('should serialize performance review reviewed', () => {
        const reviewedUsersCount = faker.number.int({ max: 20, min: 10 });
        const data = Array(reviewedUsersCount)
            .fill(1)
            .map(() => {
                return {
                    bosses: [] as User[],
                    hasPeerEvaluationType: false,
                    hasPeerExternalEvaluationType: false,
                    reviewed: generatePerformanceReviewReviewer({}),
                    user: generateRandomPerformanceReviewUser(fakePositiveInteger()),
                };
            });
        const reviewedsSerialized = new PerformanceReviewReviewedPaginatedSC().serializePaginatedList({
            count: reviewedUsersCount,
            limit: 10,
            offset: 0,
            rows: data,
        });

        expect(reviewedsSerialized.items).toHaveLength(data.length);

        reviewedsSerialized.items.forEach((reviewedDTO, index) => {
            checkPerformanceReviewReviewedSerialized(data[index], reviewedDTO);
        });
    });
});
