import { PerformanceReviewExternalReviewer } from '../../../../src/api/modules/performanceReviews/business/models/PerformanceReviewExternalReviewer';
import { PerformanceReviewUser } from '../../../../src/api/modules/performanceReviews/business/models/performanceReviewUser';
import { PerformanceReviewReviewerSC } from '../../../../src/api/modules/performanceReviews/presentation/serializationClasses/performanceReviewReviewerSC';
import {
    checkPerformanceReviewReviewerSerialized,
    generateExternalPerformanceReviewReviewer,
    generateInternalPerformanceReviewReviewer,
    generateRandomExternalReviewer,
    generateRandomPerformanceReviewUser,
} from '../common';

describe('PerformanceReviewReviewerSC', () => {
    let externalReviewersMap: Map<number, PerformanceReviewExternalReviewer>;
    let internalReviewersMap: Map<number, PerformanceReviewUser>;

    beforeEach(() => {
        externalReviewersMap = new Map<number, PerformanceReviewExternalReviewer>();
        internalReviewersMap = new Map<number, PerformanceReviewUser>();
    });

    it('should serialize internal reviewer ok', () => {
        const reviewer = generateInternalPerformanceReviewReviewer();
        internalReviewersMap.set(reviewer.reviewerId!, generateRandomPerformanceReviewUser(reviewer.reviewerId!));

        const reviewerSerialized = new PerformanceReviewReviewerSC().serialize(reviewer, { externalReviewersMap, internalReviewersMap });

        expect(reviewerSerialized).not.toBeNull();

        checkPerformanceReviewReviewerSerialized(reviewerSerialized, externalReviewersMap, internalReviewersMap, reviewer);
    });

    it('should serialize external reviewer ok', () => {
        const reviewer = generateExternalPerformanceReviewReviewer();
        externalReviewersMap.set(reviewer.externalReviewerId!, generateRandomExternalReviewer({ id: reviewer.externalReviewerId! }));
        const reviewerSerialized = new PerformanceReviewReviewerSC().serialize(reviewer, { externalReviewersMap, internalReviewersMap });

        expect(reviewerSerialized).not.toBeNull();

        checkPerformanceReviewReviewerSerialized(reviewerSerialized, externalReviewersMap, internalReviewersMap, reviewer);
    });
});
