import { faker } from '@faker-js/faker/locale/en_US';
import { ListPerformanceReviewUsersByResponsibleVC } from '../../../../src/api/modules/performanceReviews/presentation/validationClasses/listPerformanceReviewUsersByResponsibleVC';
import { fakePositiveInteger } from '../../../common/common';
import { getValidationClass } from '../../../common/serializationClasses/serializationClassesHelper';

describe('ListPerformanceReviewUsersByResponsibleVC', () => {
    it('should pass validation if the user sends correct values', () => {
        const responsibleId = fakePositiveInteger();
        const { errors } = getValidationClass(
            {
                q: faker.word.words(),
                responsibleId: faker.helpers.arrayElement([responsibleId, responsibleId.toString()]),
            },
            ListPerformanceReviewUsersByResponsibleVC,
        );

        expect(errors).toHaveLength(0);
    });

    it('should pass validation if the user sends only responsibleId', () => {
        const { errors } = getValidationClass(
            {
                responsibleId: fakePositiveInteger(),
            },
            ListPerformanceReviewUsersByResponsibleVC,
        );

        expect(errors).toHaveLength(0);
    });

    it('should validate correctly if the user sends an empty object', () => {
        const { errors } = getValidationClass({}, ListPerformanceReviewUsersByResponsibleVC);

        expect(errors).toPartiallyContain({ property: 'responsibleId' });
    });

    it('should validate correctly if the user sends incorrect types', () => {
        const { errors } = getValidationClass(
            {
                q: faker.datatype.boolean(),
                responsibleId: faker.word.words(),
            },
            ListPerformanceReviewUsersByResponsibleVC,
        );

        ['q', 'responsibleId'].forEach((property) => {
            expect(errors).toPartiallyContain({ property });
        });
    });
});
