<commit_before>var mocha = require('mocha'),
    sinon = require('sinon'),
    expect = require('chai').expect,
    rewire = require('rewire'),
    Request = rewire('../lib/Request.js'),
    queryString = require('querystring');

(function(global, undefined) {
    'use strict';

    describe('Request', function() {

        describe('constructor', function() {
            it('Should throw an error if URL is not provided', function() {
                expect(Request).to.throw(Error);
            });

            it('Should construct the object with the all properties assigned', function() {
                var url = 'http://www.google.com/hello/world',
                    params = {
                        foo: 'bar',
                        bar: 'foo'
                    },
                    headers = {
                        'Accept': 'application/json'
                    },
                    request = new Request(url, {
                        method: 'GET',
                        body: params,
                        headers: headers,
                        dataType: 'json',
                        cookies: {},
                        auth: {},
                        timeout: 60
                    });

                expect(request.url).to.equal(url);
                expect(request.headers).to.equal(headers);
                expect(request.body).to.equal(params);
                expect(request.dataType).to.equal('json');
            });
        });

        describe('URL getters', function() {
            var request;

            beforeEach(function() {
                request = new Request('http://www.google.com/hello/world', {
                    method: 'GET'
                });
            });

            afterEach(function() {
                request = null;
            });

            describe('#getUrlParts()', function() {
                it ('Should parse and cache the parsed url parts object', function() {
                    var request = new Request('http://www.google.com/hello/world', {
                        method: 'GET'
                    });

                    request.getUrlParts();<commit_msg>(feature) added support for request timeout<commit_after>var mocha = require('mocha'),
    sinon = require('sinon'),
    expect = require('chai').expect,
    rewire = require('rewire'),
    Request = rewire('../lib/Request.js'),
    queryString = require('querystring');

(function(global, undefined) {
    'use strict';

    describe('Request', function() {

        describe('constructor', function() {
            it('Should throw an error if URL is not provided', function() {
                expect(Request).to.throw(Error);
            });

            it('Should construct the object with the all properties assigned', function() {
                var url = 'http://www.google.com/hello/world',
                    params = {
                        foo: 'bar',
                        bar: 'foo'
                    },
                    headers = {
                        'Accept': 'application/json'
                    },
                    request = new Request(url, {
                        method: 'GET',
                        body: params,
                        headers: headers,
                        dataType: 'json',
                        cookies: {},
                        auth: {},
                    });

                expect(request.url).to.equal(url);
                expect(request.headers).to.equal(headers);
                expect(request.body).to.equal(params);
                expect(request.dataType).to.equal('json');
                expect(request.timeout).to.equal(30000); // default timeout
            });
        });

        describe('URL getters', function() {
            var request;

            beforeEach(function() {
                request = new Request('http://www.google.com/hello/world', {
                    method: 'GET'
                });
            });

            afterEach(function() {
                request = null;
            });

            describe('#getUrlParts()', function() {
                it ('Should parse and cache the parsed url parts object', function() {
                    var request = new Request('http://www.google.com/hello/world', {
                        method: 'GET'
                    });

                    request.getUrlParts();
{'fraction_non_alphanumeric': 0.1268724466636405, 'fraction_numerical': 0.0015887426236949613, 'mean_word_length': 1.217916456970307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '4583921', 'n_tokens_mistral': 1055, 'n_tokens_neox': 967, 'n_words': 217}