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

describe('GetPerformanceReviewReviewersOfReviewedVC', () => {
    it('should pass validation if the user sends an empty object', () => {
        const { errors, output } = getValidationClass({}, GetPerformanceReviewReviewersOfReviewedVC);

        expect(errors).toHaveLength(0);
        expect(output.onlyExternalReviewers).toBeUndefined();
    });

    it('should pass validation if the user sends correct string params', () => {
        const value = faker.helpers.arrayElement(['true', 'false']);
        const { errors, output } = getValidationClass(
            {
                onlyExternalReviewers: value,
            },
            GetPerformanceReviewReviewersOfReviewedVC,
        );

        expect(errors).toHaveLength(0);
        expect(output.onlyExternalReviewers).toBe(value === 'true');
    });

    it('should pass validation if the user sends correct boolean params', () => {
        const { errors } = getValidationClass(
            {
                onlyExternalReviewers: faker.datatype.boolean(),
            },
            GetPerformanceReviewReviewersOfReviewedVC,
        );

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

    it('should pass validation if the user sends other string params', () => {
        const { errors, output } = getValidationClass(
            {
                onlyExternalReviewers: faker.word.words(),
            },
            GetPerformanceReviewReviewersOfReviewedVC,
        );

        expect(errors).toHaveLength(0);
        expect(output.onlyExternalReviewers).toBeFalse();
    });

    it('should pass validation if the user sends other type params', () => {
        const { errors, output } = getValidationClass(
            {
                onlyExternalReviewers: fakePositiveInteger(),
            },
            GetPerformanceReviewReviewersOfReviewedVC,
        );

        expect(errors).toHaveLength(0);
        expect(output.onlyExternalReviewers).toBeFalse();
    });
});
