<commit_before>'use strict';

var expect = require('chai').expect;
var Response = require('../lib/response');
var Request = require('../lib/request');

describe('Response', function () {
    it('should be instantiable', function () {
        expect(new Response()).to.be.an('object');
    });

    it('should pass through a Request parameter', function () {
        var request = new Request();
        var response = new Response(request);
        expect(response.request).to.eql(request);
    });

    it('should have basic properties', function () {
        var request = new Request();
        var response = new Response(request);
        expect(response.meta).to.be.an('object');
        expect(response.meta.headers).to.be.an('object');
        expect(response.data).to.eql(null);
    });

    it('should not expose headers in response.meta', function (done) {
        var request = new Request();
        var response = new Response(request, function (err, res) {
            expect(res.meta.propertyIsEnumerable('headers')).to.equal(false);
            done();
        });
        response.send();
    });

    it('should have default status code', function () {
        var request = new Request();
        var response = new Response(request);
        expect(response.meta.statusCode).to.eql(200);
    });

    describe('send', function () {
        it('should call the callback', function (done) {
            var request = new Request();
            var response = new Response(request, function (err) {
                expect(err).to.eql(null);
                done();
            });
            response.send();
        });

        it('should pass through the payload', function (done) {
            var request = new Request();
            var response = new Response(request, function (err, res) {
                expect(res).to.eql(response);
                expect(res.data).to.eql('foo');
                done();
            });
            response.send('foo');
        });

        it('should pass through Errors', function (done) {
            var request = new Request();
            var response = new Response(request, function (err, res) {
                expect(err).to.be.an.instanceof(Error);
                expect(res).to.be.undefined;
                done();
            });
            response.send(new Error('bar'));
        });

        it('cannot be called twice', function (done) {
            var count = 0;
            var request = new Request();
            var response = new Response(request, function (err, res) {
                count++;
                if (count === 1) {
                    res.send('baz');
                } else if (count === 2) {
                    expect(err).to.be.an('error');
                    expect(err.message).to.equal('Response#send was already called');
                    done();
                }
            });
            response.send('foo');
        });
    });
});<commit_msg>Inline variable<commit_after>'use strict';

var expect = require('chai').expect;
var Response = require('../lib/response');
var Request = require('../lib/request');

describe('Response', function () {
    it('should be instantiable', function () {
        expect(new Response()).to.be.an('object');
    });

    it('should pass through a Request parameter', function () {
        var request = new Request();
        var response = new Response(request);
        expect(response.request).to.eql(request);
    });

    it('should have basic properties', function () {
        var response = new Response(new Request());
        expect(response.meta).to.be.an('object');
        expect(response.meta.headers).to.be.an('object');
        expect(response.data).to.eql(null);
    });

    it('should not expose headers in response.meta', function (done) {
        var response = new Response(new Request(), function (err, res) {
            expect(res.meta.propertyIsEnumerable('headers')).to.equal(false);
            done();
        });
        response.send();
    });

    it('should have default status code', function () {
        var response = new Response(new Request());
        expect(response.meta.statusCode).to.eql(200);
    });

    describe('send', function () {
        it('should call the callback', function (done) {
            var response = new Response(new Request(), function (err) {
                expect(err).to.eql(null);
                done();
            });
            response.send();
        });

        it('should pass through the payload', function (done) {
            var response = new Response(new Request(), function (err, res) {
                expect(res).to.eql(response);
                expect(res.data).to.eql('foo');
                done();
            });
            response.send('foo');
        });

        it('should pass through Errors', function (done) {
            var response = new Response(new Request(), function (err, res) {
                expect(err).to.be.an.instanceof(Error);
                expect(res).to.be.undefined;
                done();
            });
            response.send(new Error('bar'));
        });

        it('cannot be called twice', function (done) {
            var count = 0;
            var response = new Response(new Request(), function (err, res) {
                count++;
                if (count === 1) {
                    res.send('baz');
                } else if (count === 2) {
                    expect(err).to.be.an('error');
                    expect(err.message).to.equal('Response#send was already called');
                    done();
                }
            });
            response.send('foo');
        });
    });
});
{'fraction_non_alphanumeric': 0.15104257928859297, 'fraction_numerical': 0.0021026809181706675, 'mean_word_length': 1.811822660098522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5769535', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1425, 'n_words': 358}