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

describe('CreatePerformanceReviewExternalReviewerVC', () => {
    it(`should pass validation if the user sends a correct payload`, () => {
        const { errors } = getValidationClass(
            {
                email: faker.internet.email(),
                firstName: faker.word.words(),
                lastName: faker.word.words(),
            },
            CreatePerformanceReviewExternalReviewerVC,
        );

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

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

        ['email', 'firstName', 'lastName'].forEach((property) => {
            expect(errors).toPartiallyContain({ property });
        });
    });

    it('should validate correctly if the user sends incorrect firstName', () => {
        const { errors } = getValidationClass(
            {
                email: faker.internet.email(),
                firstName: faker.datatype.boolean(),
                lastName: faker.word.words(),
            },
            CreatePerformanceReviewExternalReviewerVC,
        );

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

    it('should validate correctly if the user sends incorrect lastName', () => {
        const { errors } = getValidationClass(
            {
                email: faker.internet.email(),
                firstName: faker.word.words(),
                lastName: faker.datatype.boolean(),
            },
            CreatePerformanceReviewExternalReviewerVC,
        );

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

    it('should validate correctly if the user sends incorrect email', () => {
        const { errors } = getValidationClass(
            {
                email: faker.word.words(),
                firstName: faker.word.words(),
                lastName: faker.word.words(),
            },
            CreatePerformanceReviewExternalReviewerVC,
        );

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

    it(`should validate correctly if the user sends '' as firstName`, () => {
        const { errors } = getValidationClass(
            {
                email: faker.word.words(),
                firstName: '',
                lastName: faker.word.words(),
            },
            CreatePerformanceReviewExternalReviewerVC,
        );

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

    it(`should validate correctly if the user sends '' as lastName`, () => {
        const { errors } = getValidationClass(
            {
                email: faker.word.words(),
                firstName: faker.word.words(),
                lastName: '',
            },
            CreatePerformanceReviewExternalReviewerVC,
        );

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