<commit_before>/* jshint node: true */
/* global describe, beforeEach, afterEach, it, jasmine, expect */
'use strict';
describe('registration on post', function () {

    var extractParticipant;
    var validRequestData = {
        body: {
            firstname: 'Mark',
            lastname: 'Mueller',
            email: '<EMAIL>'
        }
    };

    beforeEach(function () {
        extractParticipant = require('../routes/registration.js').extractParticipant;
    });

    it('should read firstname from the request body', function () {
        expect(extractParticipant(validRequestData).firstname).toBe('Mark');
    });

    it('should throw an error if no firstname can be found', function () {
        var extractParticipant = require('../routes/registration.js').extractParticipant;

        function callWithNoFirstname() {
            extractParticipant({body: {}});
        }

        expect(callWithNoFirstname).toThrow();
    });

    it('should throw an error if no lastname can be found', function () {
        var extractParticipant = require('../routes/registration.js').extractParticipant;

        function callWithNoFirstname() {
            extractParticipant({body: {firstName: 'XX'}});
        }

        expect(callWithNoFirstname).toThrow();
    });
    
    it('should throw an error if no email can be found', function () {
        var extractParticipant = require('../routes/registration.js').extractParticipant;

        function callWithNoEmail() {
            extractParticipant({body: {firstName: 'XX', lastName: 'YY'}});
        }

        expect(callWithNoEmail).toThrow();
    });

    it('should read lastname from the request body', function () {
        expect(extractParticipant(validRequestData).lastname).toBe('Mueller');
    });


    it('should read email from the request body', function () {
        expect(extractParticipant(validRequestData).email).toBe('<EMAIL>');
    });


});<commit_msg>moved the function init. to the before block.<commit_after>/* jshint node: true */
/* global describe, beforeEach, afterEach, it, jasmine, expect */
'use strict';
describe('registration on post', function () {

    var extractParticipant;
    var validRequestData = {
        body: {
            firstname: 'Mark',
            lastname: 'Mueller',
            email: '<EMAIL>'
        }
    };

    beforeEach(function () {
        extractParticipant = require('../routes/registration.js').extractParticipant;
    });

    it('should read firstname from the request body', function () {
        expect(extractParticipant(validRequestData).firstname).toBe('Mark');
    });

    it('should throw an error if no firstname can be found', function () {
        function callWithNoFirstname() {
            extractParticipant({body: {}});
        }

        expect(callWithNoFirstname).toThrow();
    });

    it('should throw an error if no lastname can be found', function () {
        function callWithNoFirstname() {
            extractParticipant({body: {firstName: 'XX'}});
        }

        expect(callWithNoFirstname).toThrow();
    });
    
    it('should throw an error if no email can be found', function () {
        function callWithNoEmail() {
            extractParticipant({body: {firstName: 'XX', lastName: 'YY'}});
        }

        expect(callWithNoEmail).toThrow();
    });

    it('should read lastname from the request body', function () {
        expect(extractParticipant(validRequestData).lastname).toBe('Mueller');
    });


    it('should read email from the request body', function () {
        expect(extractParticipant(validRequestData).email).toBe('<EMAIL>');
    });
});
{'fraction_non_alphanumeric': 0.1363011816433086, 'fraction_numerical': 0.0, 'mean_word_length': 2.81151832460733, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '629080', 'n_tokens_mistral': 1014, 'n_tokens_neox': 957, 'n_words': 234}