<commit_before>import './helpers/setup-test-env.ts';
import * as test from 'tape';
import * as React from 'react';
import { shallow, mount } from 'enzyme';
import { QuestionPageData } from '../src/templates/types';
import QuestionPage from '../src/templates/presentation/QuestionPage';

const submitQuestionMockCorrect = (t: test.Test) => {
    return (question_key: number, answer: string, correct: boolean) => {
        t.true(correct);
        t.end();
    };
};

const submitQuestionMockIncorrect = (t: test.Test) => {
    return (question_key: number, answer: string, correct: boolean) => {
        t.false(correct);
        t.end();
    };
};

test('should be a question 1', t => {
    const STEM = 'this should be the title';
    const ANSWERS = [
        'is this the answer',
            'or is this',
            'maybe this'
    ];
    const FEEDBACK = 'you did the thing! I don\'t care';

    const props: QuestionPageData = {
        type: 'question',
        stem: STEM,
        answers: ANSWERS,
        correct: 2,
        feedback: FEEDBACK,
        index: 0,
        submitQuestion: submitQuestionMockCorrect(t)
    };

    const wrapper = shallow(QuestionPage(props));
    const stem = wrapper.find('.stem');
    const h3 = wrapper.find('h3');
    const form = wrapper.find('form');
    const feedback = wrapper.find('.feedback');

    t.is(stem.text(), STEM);
    t.is(feedback.text(), FEEDBACK);
    t.is(h3.text(), 'Question 1');
    t.end();
});

test('should be a question 2', t => {
    const STEM = 'this is another title';
    const ANSWERS = [
        'is this the answer',
            'or is this',
            'maybe this'
    ];
    const FEEDBACK = 'you did the thing! I DO care, color me suprised';

    const props: QuestionPageData = {
        type: 'question',
        stem: STEM,
        answers: ANSWERS,
        correct: 2,
        feedback: FEEDBACK,
        index: 4,
        submitQuestion: submitQuestionMockCorrect(t)
    };

    const wrapper = shallow(QuestionPage(props));
    const stem = wrapper.find('.stem');
    const h3 = wrapper.find('h3');
    const form = wrapper.find('form');
    const feedback = wrapper.find('.feedback');

    t.is(stem.text(), STEM);
    t.is(feedback.text(), FEEDBACK);
    t.is(h3.text(), 'Question 5');
    t.end();
});

test('should answer the question', t => {
    const STEM = 'this is another title';
    const ANSWERS = [
        'is this the answer',
            'or is this',
            'maybe this'
    ];
    const FEEDBACK = 'you did the thing! I DO care, color me suprised';

    const props: QuestionPageData = {
        type: 'question',
        stem: STEM,
        answers: ANSWERS,
        correct: 2,
        feedback: FEEDBACK,
        index: 4,
        submitQuestion: submitQuestionMockCorrect(t)
    };

    const wrapper = mount(QuestionPage(props)).find('.page');
    const inputAnswer = wrapper.find('#radio_4_2');
    const form = wrapper.find('form');
    t.equal(wrapper.length, 1);
    t.equal(inputAnswer.length, 1);
    inputAnswer.simulate('click');
    form.simulate('submit');
});<commit_msg>Little bit more testing<commit_after>import './helpers/setup-test-env.ts';
import * as test from 'tape';
import * as React from 'react';
import { shallow, mount } from 'enzyme';
import { QuestionPageData } from '../src/templates/types';
import QuestionPage from '../src/templates/presentation/QuestionPage';

const submitQuestionMockCorrectAndEndTest = (t: test.Test) => {
    return (question_key: number, answer: string, correct: boolean) => {
        t.true(correct);
        t.end();
    };
};

const submitQuestionMockIncorrectAndEndTest = (t: test.Test) => {
    return (question_key: number, answer: string, correct: boolean) => {
        t.false(correct);
        t.end();
    };
};

test('should be a question 1', t => {
    const STEM = 'this should be the title';
    const ANSWERS = [
        'is this the answer',
            'or is this',
            'maybe this'
    ];
    const FEEDBACK = 'you did the thing! I don\'t care';

    const props: QuestionPageData = {
        type: 'question',
        stem: STEM,
        answers: ANSWERS,
        correct: 2,
        feedback: FEEDBACK,
        index: 0,
        submitQuestion: submitQuestionMockCorrectAndEndTest(t)
    };

    const wrapper = shallow(QuestionPage(props));
    const stem = wrapper.find('.stem');
    const h3 = wrapper.find('h3');
    const form = wrapper.find('form');
    const feedback = wrapper.find('.feedback');

    t.is(stem.text(), STEM);
    t.is(feedback.text(), FEEDBACK);
    t.is(h3.text(), 'Question 1');
    t.end();
});

test('should be a question 2', t => {
    const STEM = 'this is another title';
    const ANSWERS = [
        'is this the answer',
            'or is this',
            'maybe this'
    ];
    const FEEDBACK = 'you did the thing! I DO care, color me suprised';

    const props: QuestionPageData = {
        type: 'question',
        stem: STEM,
        answers: ANSWERS,
        correct: 2,
        feedback: FEEDBACK,
        index: 4,
        submitQuestion: submitQuestionMockCorrectAndEndTest(t)
    };

    const wrapper = shallow(QuestionPage(props));
    const stem = wrapper.find('.stem');
    const h3 = wrapper.find('h3');
    const form = wrapper.find('form');
    const feedback = wrapper.find('.feedback');

    t.is(stem.text(), STEM);
    t.is(feedback.text(), FEEDBACK);
    t.is(h3.text(), 'Question 5');
    t.end();
});

test('should answer the question correcly', t => {
    const STEM = 'this is another title';
    const ANSWERS = [
        'is this the answer',
            'or is this',
            'maybe this'
    ];
    const FEEDBACK = 'you did the thing! I DO care, color me suprised';

    const props: QuestionPageData = {
        type: 'question',
        stem: STEM,
        answers: ANSWERS,
        correct: 2,
        feedback: FEEDBACK,
        index: 4,
        submitQuestion: submitQuestionMockCorrectAndEndTest(t)
    };

    const wrapper = mount(QuestionPage(props)).find('.page');
    const inputAnswer = wrapper.find('#radio_4_2');
    const form = wrapper.find('form');
    t.equal(wrapper.length, 1);
    t.equal(inputAnswer.length, 1);
    inputAnswer.simulate('click');
    form.simulate('submit');
});

test('should answer the question incorrectly', t => {
    const STEM = 'this is another title';
    const ANSWERS = [
        'is this the answer',
            'or is this',
            'maybe this'
    ];
    const FEEDBACK = 'you did the thing! I DO care, color me suprised';

    const props: QuestionPageData = {
        type: 'question',
        stem: STEM,
        answers: ANSWERS,
        correct: 2,
        feedback: FEEDBACK,
        index: 4,
        submitQuestion: submitQuestionMockIncorrectAndEndTest(t)
    };

    const wrapper = mount(QuestionPage(props)).find('.page');
    const inputAnswer = wrapper.find('#radio_4_0');
    const form = wrapper.find('form');
    t.equal(wrapper.length, 1);
    t.equal(inputAnswer.length, 1);
    inputAnswer.simulate('click');
    form.simulate('submit');
});
{'fraction_non_alphanumeric': 0.14185096492463728, 'fraction_numerical': 0.006479785885335963, 'mean_word_length': 2.5270740188772978, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6115928', 'n_tokens_mistral': 2217, 'n_tokens_neox': 2124, 'n_words': 601}