import { PerformanceReviewGoalQuestionWithAnswer } from '../../../../src/api/modules/performanceReviews/business/models/performanceReviewGoalQuestionWithAnswer';
import { PerformanceReviewGoalQuestionSC } from '../../../../src/api/modules/performanceReviews/presentation/serializationClasses/performanceReviewGoalQuestionSC';
import { generateRandomGoal } from '../../goals/common';
import { checkPerformanceReviewGoalQuestionSerialized, generateGoalQuestionWithAnswer } from '../common';

describe('PerformanceReviewGoalQuestionSC', () => {
    let goalQuestion: PerformanceReviewGoalQuestionWithAnswer;

    beforeEach(() => {
        goalQuestion = generateGoalQuestionWithAnswer();
    });

    it('should serialize goal question without goal', () => {
        const goalQuestionSerialized = new PerformanceReviewGoalQuestionSC().serialize(goalQuestion);

        expect(goalQuestionSerialized).not.toBeNull();

        checkPerformanceReviewGoalQuestionSerialized(goalQuestion, goalQuestionSerialized);
    });

    it('should serialize goal question without goal and questionWithAnswer', () => {
        goalQuestion.questionWithAnswer = null;
        const goalQuestionSerialized = new PerformanceReviewGoalQuestionSC().serialize(goalQuestion);

        expect(goalQuestionSerialized).not.toBeNull();

        checkPerformanceReviewGoalQuestionSerialized(goalQuestion, goalQuestionSerialized);
    });

    it('should serialize goal question with goal', () => {
        goalQuestion.goal = generateRandomGoal();
        const goalQuestionSerialized = new PerformanceReviewGoalQuestionSC().serialize(goalQuestion);

        expect(goalQuestionSerialized).not.toBeNull();

        checkPerformanceReviewGoalQuestionSerialized(goalQuestion, goalQuestionSerialized);
    });
});
