import { faker } from '@faker-js/faker/locale/en_US';
import { PerformanceReviewFormEditRequestFinalStatus } from '../../../../src/api/modules/performanceReviews/business/types/performanceReviewFormEditRequestStatus';
import { ReviewPerformanceReviewFormReviewEditRequestVC } from '../../../../src/api/modules/performanceReviews/presentation/validationClasses/reviewPerformanceReviewFormReviewEditRequestVC';
import { getValidationClass } from '../../../common/serializationClasses/serializationClassesHelper';

describe('ReviewPerformanceReviewFormReviewEditRequestVC', () => {
    it(`should pass validation if the user sends a correct payload`, () => {
        const { errors } = getValidationClass(
            {
                description: faker.word.words(),
                status: faker.helpers.arrayElement(Object.values(PerformanceReviewFormEditRequestFinalStatus)),
            },
            ReviewPerformanceReviewFormReviewEditRequestVC,
        );

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

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

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

    it('should validate correctly if the user sends incorrect description', () => {
        const { errors } = getValidationClass(
            {
                description: faker.datatype.boolean(),
                status: faker.helpers.arrayElement(Object.values(PerformanceReviewFormEditRequestFinalStatus)),
            },
            ReviewPerformanceReviewFormReviewEditRequestVC,
        );

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

    it(`should validate correctly if the user sends '' as description`, () => {
        const { errors } = getValidationClass(
            {
                description: '',
                status: faker.helpers.arrayElement(Object.values(PerformanceReviewFormEditRequestFinalStatus)),
            },
            ReviewPerformanceReviewFormReviewEditRequestVC,
        );

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