import { faker } from '@faker-js/faker/locale/en_US';
import { PerformanceReviewCycleParticipantType } from '../../../../src/api/modules/performanceReviews/business/types/performanceReviewCycleRole';
import { ListPerformanceReviewUsersByParticipantTypeVC } from '../../../../src/api/modules/performanceReviews/presentation/validationClasses/listPerformanceReviewUsersByParticipantTypeVC';
import { getValidationClass } from '../../../common/serializationClasses/serializationClassesHelper';

describe('ListPerformanceReviewUsersByParticipantTypeVC', () => {
    it('should pass validation if the user sends only a role', () => {
        const { errors } = getValidationClass(
            {
                role: faker.helpers.arrayElement(Object.values(PerformanceReviewCycleParticipantType)),
            },
            ListPerformanceReviewUsersByParticipantTypeVC,
        );

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

    it('should pass validation if the user sends role and correct q', () => {
        const { errors } = getValidationClass(
            {
                q: faker.word.words(),
                role: faker.helpers.arrayElement(Object.values(PerformanceReviewCycleParticipantType)),
            },
            ListPerformanceReviewUsersByParticipantTypeVC,
        );

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

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

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

    it('should validate correctly if the user sends an invalid role', () => {
        const { errors } = getValidationClass(
            {
                role: faker.word.words(),
            },
            ListPerformanceReviewUsersByParticipantTypeVC,
        );

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

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

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