import { PerformanceReviewFormReview } from '../../../../src/api/modules/performanceReviews/business/models/performanceReviewFormReview';
import { PerformanceReviewFormReviewWithFormDetailsSC } from '../../../../src/api/modules/performanceReviews/presentation/serializationClasses/performanceReviewFormReviewWithFormDetailsSC';
import { fakePositiveInteger } from '../../../common/common';
import { generateRandomCoreFormWithQuestions } from '../../../kernels/forms/common';
import {
    checkPerformanceReviewFormReviewSerializedWithCoreForm,
    generateGoalQuestionWithAnswerAndGoal,
    generateRandomPerformanceReviewFormReview,
} from '../common';

describe('PerformanceReviewFormReviewWithFormDetailsSC', () => {
    let reviewForm: PerformanceReviewFormReview;

    beforeEach(() => {
        reviewForm = generateRandomPerformanceReviewFormReview(fakePositiveInteger());
    });

    it('should serialize review form without core form', () => {
        const reviewFormSerialized = new PerformanceReviewFormReviewWithFormDetailsSC().serialize(reviewForm);

        expect(reviewFormSerialized).not.toBeNull();

        checkPerformanceReviewFormReviewSerializedWithCoreForm(reviewForm, reviewFormSerialized);
    });

    it('should serialize review form with core form', () => {
        reviewForm.coreForm = generateRandomCoreFormWithQuestions(reviewForm.coreFormTag!, reviewForm.coreFormId!);

        const reviewFormSerialized = new PerformanceReviewFormReviewWithFormDetailsSC().serialize(reviewForm);

        expect(reviewFormSerialized).not.toBeNull();

        checkPerformanceReviewFormReviewSerializedWithCoreForm(reviewForm, reviewFormSerialized);
    });

    it('should serialize review form with core form and goals', () => {
        reviewForm.coreForm = generateRandomCoreFormWithQuestions(reviewForm.coreFormTag!, reviewForm.coreFormId!);
        reviewForm.goalQuestionsWithAnswer = [generateGoalQuestionWithAnswerAndGoal()];

        const reviewFormSerialized = new PerformanceReviewFormReviewWithFormDetailsSC().serialize(reviewForm);

        expect(reviewFormSerialized).not.toBeNull();

        checkPerformanceReviewFormReviewSerializedWithCoreForm(reviewForm, reviewFormSerialized);
    });
});
