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

describe('EditPerformanceReviewReviewersVC', () => {
    it(`should pass validation if the user sends correct parameters`, () => {
        const { errors } = getValidationClass(
            {
                externalReviewerIds: [fakePositiveInteger()],
                reviewerIds: [fakePositiveInteger()],
            },
            EditPerformanceReviewReviewersVC,
        );

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

    it('should pass validation if the user sends null', () => {
        const { errors } = getValidationClass(
            {
                externalReviewerIds: null,
                reviewerIds: null,
            },
            EditPerformanceReviewReviewersVC,
        );

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

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

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

    it('should validate correctly if the user sends incorrect types', () => {
        const { errors } = getValidationClass(
            {
                reviewerIds: faker.word.words(),
            },
            EditPerformanceReviewReviewersVC,
        );

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