"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = __importDefault(require("lodash"));
const react_1 = __importDefault(require("react"));
const react_i18next_1 = require("react-i18next");
const react_test_renderer_1 = require("react-test-renderer");
const QuestionContext_1 = require("../../src/components/context/QuestionContext");
const QuestionManualScore_1 = __importDefault(require("../../src/components/results/internal/QuestionManualScore"));
const i18n_1 = require("../../src/i18n");
const defaultProps = {
    maxScore: 6,
    displayNumber: '1',
    questionId: 1
};
const defaultScores = {
    questionId: 1,
    answerId: 1,
    pregrading: { score: 1, annotations: [] },
    censoring: {
        scores: [
            { score: 4, shortCode: 'SE3' },
            { score: 3, shortCode: 'SE2' },
            { score: 2, shortCode: 'SE1' }
        ],
        annotations: [],
        nonAnswerDetails: {}
    },
    inspection: { score: 5, shortCodes: ['IN1', 'IN2'] }
};
describe('<QuestionManualScore />', () => {
    let i18n;
    describe('fi-FI', () => {
        beforeAll(() => {
            i18n = (0, i18n_1.initI18n)('fi-FI');
        });
        it('renders without score', () => {
            const props = {
                ...defaultProps,
                scores: undefined
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
        it('renders with pregrading score', () => {
            const props = {
                ...defaultProps,
                scores: lodash_1.default.pick(defaultScores, 'pregrading', 'answerId', 'questionId')
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
        it('renders with pregrading and one censor scores', () => {
            const props = {
                ...defaultProps,
                scores: {
                    censoring: { scores: [defaultScores.censoring.scores[0]] },
                    ...lodash_1.default.pick(defaultScores, 'pregrading', 'answerId', 'questionId')
                }
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
        it('renders with pregrading and three censor scores', () => {
            const props = {
                ...defaultProps,
                scores: lodash_1.default.pick(defaultScores, 'pregrading', 'censoring', 'answerId', 'questionId')
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
        it('renders with pregrading, censor and inspection scores', () => {
            const props = {
                ...defaultProps,
                scores: defaultScores
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
        it('renders with displayNumber where there are more than one answer', () => {
            const props = {
                ...defaultProps,
                scores: lodash_1.default.pick(defaultScores, 'pregrading', 'answerId', 'questionId')
            };
            expect(renderWithContext(props, [{}, {}]).toJSON()).toMatchSnapshot();
        });
        it('renders with NoPregrading when there are no scores', () => {
            const props = {
                ...defaultProps,
                scores: lodash_1.default.pick(defaultScores, 'answerId', 'questionId')
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
        it('renders with NoPregrading when there is pregrading data but no scores', () => {
            const props = {
                ...defaultProps,
                scores: {
                    preGrading: { comment: 'comment' },
                    ...lodash_1.default.pick(defaultScores, 'answerId', 'questionId')
                }
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
        it('renders without NoPregrading when pregrading score is 0', () => {
            const props = {
                ...defaultProps,
                scores: {
                    pregrading: { score: 0 },
                    ...lodash_1.default.pick(defaultScores, 'answerId', 'questionId')
                }
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
        it('renders without NoPregrading when there are scores', () => {
            const props = {
                ...defaultProps,
                scores: lodash_1.default.pick(defaultScores, 'answerId', 'questionId', 'pregrading', 'censoring')
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
    });
    describe('sv-FI', () => {
        it('renders with pregrading, censor and inspection scores', () => {
            i18n = (0, i18n_1.initI18n)('fi-SV');
            const props = {
                ...defaultProps,
                scores: defaultScores
            };
            expect(renderWithContext(props, []).toJSON()).toMatchSnapshot();
        });
    });
    const contextProps = {
        answers: [],
        displayNumber: '1',
        hasExternalMaterial: false,
        maxAnswers: 2,
        maxScore: 2,
        level: 2,
        childQuestions: [],
        questionLabelIds: ''
    };
    function renderWithContext(props, answers) {
        return (0, react_test_renderer_1.create)(react_1.default.createElement(QuestionContext_1.QuestionContext.Provider, { value: { ...contextProps, answers } },
            react_1.default.createElement(react_i18next_1.I18nextProvider, { i18n: i18n },
                react_1.default.createElement(QuestionManualScore_1.default, { ...props }))));
    }
});
//# sourceMappingURL=ResultsExamQuestionManualScore.test.js.map