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

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

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

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

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

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

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

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

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

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

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