<commit_before>chai     = require "chai"
XHR      = require "../lib/node.js"
settings = require "madlib-settings"
NodeXHR  = require "xmlhttprequest"

describe( "XHR Timeout", () ->
    describe( "#call()", () ->
        it( "Should return HTTP 408", ( testCompleted ) ->

            # Set an absurdly short timeout
            # For some reason numeric value doesn't work
            # Might be an issue with NodeXHR implementation
            #
            settings.set( "xhr.timeout", null )

            xhr = new XHR( settings )

            # Override method to create working transport for testing purposes
            #
            xhr.createTransport = () ->
                return new NodeXHR.XMLHttpRequest()

            xhr.call(
                url:      "http://labs.marviq.net/xdm/example.json"
                method:   "GET"
                type:     "json"
            )
            .then(
                ( data ) ->
                    # console.log( data )
                    chai.expect( data.status ).to.eql( 408 )
                    testCompleted();
                ( error ) ->
                    # console.log( error )
                    chai.expect( error.status ).to.eql( 408 )<commit_msg>Also fixed second unit test >.<<commit_after>chai     = require "chai"
XHR      = require "../lib/node.js"
settings = require "madlib-settings"
NodeXHR  = require "xmlhttprequest"

describe( "XHR Timeout", () ->
    describe( "#call()", () ->
        it( "Should return HTTP 408", ( testCompleted ) ->

            # Set an absurdly short timeout
            # For some reason numeric value doesn't work
            # Might be an issue with NodeXHR implementation
            #
            settings.set( "xhr.timeout", null )

            xhr = new XHR( settings )

            # Override method to create working transport for testing purposes
            #
            xhr.createTransport = () ->
                return new NodeXHR.XMLHttpRequest()

            xhr.call(
                url:      "http://www.qwerios.nl/projects/xdm/example.json"
                method:   "GET"
                type:     "json"
            )
            .then(
                ( data ) ->
                    # console.log( data )
                    chai.expect( data.status ).to.eql( 408 )
                    testCompleted();
                ( error ) ->
                    # console.log( error )
                    chai.expect( error.status ).to.eql( 408 )
{'fraction_non_alphanumeric': 0.1076051779935275, 'fraction_numerical': 0.007281553398058253, 'mean_word_length': 1.3026070763500932, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 2}, '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': '1262633', 'n_tokens_mistral': 689, 'n_tokens_neox': 633, 'n_words': 175}