<commit_before>(function() {
    var chai = require('chai'),
        should = chai.should(),
        expect = chai.expect,
        sinon = require('sinon');

    var FreegeoipGeocoder = require('../../lib/geocoder/freegeoipgeocoder.js');

    var mockedHttpAdapter = {
        get: function() {}
    };

    describe('FreegeoipGeocoder', function() {

        describe('#constructor' , function() {

            it('an http adapter must be set', function() {

                expect(function() {new FreegeoipGeocoder();}).to.throw(Error, 'FreegeoipGeocoder need an httpAdapter');
            });

            it('Should be an instance of FreegeoipGeocoder', function() {

                var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter);

                freegeoipgeocoder.should.be.instanceof(FreegeoipGeocoder);
            });

        });

        describe('#geocode' , function() {

            it('Should not accept address', function() {

                var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter);
                expect(function() {freegeoipgeocoder.geocode('1 rue test');})
                    .to
                    .throw(Error, 'FreegeoipGeocoder does not support geocoding address');


            });

            it('Should call httpAdapter get method', function() {

                var mock = sinon.mock(mockedHttpAdapter);
                mock.expects('get').once().returns({then: function() {}});

                var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter);

                freegeoipgeocoder.geocode('127.0.0.1');

                mock.verify();
            });

            it('Should return a geocoded address', function(done) {
                var mock = sinon.mock(mockedHttpAdapter);
                mock.expects('get').once().callsArgWith(2, false, {
                        latitude: 37.386,
                        longitude: -122.0838,
                        country_code: 'US',
                        country_name: 'United States',
                        city: 'Mountain View',
                        zipcode: 94035
                    }
                );
                var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter);
                

                freegeoipgeocoder.geocode('66.249.64.0', function(err, results) {
                    err.should.to.equal(false);
                    results[0].should.to.deep.equal({
                        "latitude": 37.386,
                        "longitude": -122.0838,
                        "country": "United States",
                        "city": "Mountain View",
                        "zipcode": 94035,
                        "streetName": null,<commit_msg>fixing test<commit_after>(function() {
    var chai = require('chai'),
        should = chai.should(),
        expect = chai.expect,
        sinon = require('sinon');

    var FreegeoipGeocoder = require('../../lib/geocoder/freegeoipgeocoder.js');

    var mockedHttpAdapter = {
        get: function() {}
    };

    describe('FreegeoipGeocoder', function() {

        describe('#constructor' , function() {

            it('an http adapter must be set', function() {

                expect(function() {new FreegeoipGeocoder();}).to.throw(Error, 'FreegeoipGeocoder need an httpAdapter');
            });

            it('Should be an instance of FreegeoipGeocoder', function() {

                var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter);

                freegeoipgeocoder.should.be.instanceof(FreegeoipGeocoder);
            });

        });

        describe('#geocode' , function() {

            it('Should not accept address', function() {

                var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter);
                expect(function() {freegeoipgeocoder.geocode('1 rue test');})
                    .to
                    .throw(Error, 'FreegeoipGeocoder does not support geocoding address');


            });

            it('Should call httpAdapter get method', function() {

                var mock = sinon.mock(mockedHttpAdapter);
                mock.expects('get').once().returns({then: function() {}});

                var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter);

                freegeoipgeocoder.geocode('127.0.0.1');

                mock.verify();
            });

            it('Should return a geocoded address', function(done) {
                var mock = sinon.mock(mockedHttpAdapter);
                mock.expects('get').once().callsArgWith(2, false, {
                        latitude: 37.386,
                        longitude: -122.0838,
                        country_code: 'US',
                        country_name: 'United States',
                        city: 'Mountain View',
                        zipcode: 94035
                    }
                );
                var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter);


                freegeoipgeocoder.geocode('172.16.58.3', function(err, results) {
                    err.should.to.equal(false);
                    results[0].should.to.deep.equal({
                        "latitude": 37.386,
                        "longitude": -122.0838,
                        "country": "United States",
                        "city": "Mountain View",
                        "zip_code": 94035,
                        "streetName": null,
{'fraction_non_alphanumeric': 0.11697627368033842, 'fraction_numerical': 0.0187603457789222, 'mean_word_length': 1.5578551269990593, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '5982592', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1395, 'n_words': 270}