<commit_before>
var should  = require('chai').should();
var nock    = require('nock')

var cell2coords  = require('../src/cell2coords.js');

describe("Cell2Coords module", function() {

  describe("Translate cellular info into coordinates", function() {

    var api_resp = {"apiVersion":"2","CID":"13564400","LAC":"20601","phone_type":"GSM",
        "SID":null,"network_id":null,"perMinuteCurrent":0,"perMinuteLimit":10,
        "perMonthCurrent":34,"perMonthLimit":2000,"tower1":{"phone_type":"GSM","psc":0,
        "cid":13564400,"lac":20601,"est_lat":"59.90981531125","est_lng":"10.77598607375",
        "est_acc":"236.7925","est_stddev":"0.25","2G":0,"3G":1,"4G":0,"network_id_main":2420,
        "network_ids_json_out":"NULL"}};

    before(function(){
      nock('http://api.opensignal.com')
        .get(/v2\/towerinfo\.json\?cid=\d+&lac=\d+&apikey=\w+$/)
        .reply(200, JSON.stringify(api_resp));
    });

    it("converts {cid, lac} into {lat,lng}", function(done) {

      cell2coords({cid: 13564400, lac: 20601}, function(error, coords) {
        should.not.exist(error);
        coords.lat.should.equal('59.90981531125');
        coords.lng.should.equal('10.77598607375');

        done();
      });

    });

  });

});<commit_msg>ISSUE #13 Add test for http response errors<commit_after>
var should  = require('chai').should();
var nock    = require('nock')

var cell2coords  = require('../src/cell2coords.js');

describe("Cell2Coords module", function() {

  describe("Translate cellular info into coordinates", function() {

    var api_resp = {"apiVersion":"2","CID":"13564400","LAC":"20601","phone_type":"GSM",
        "SID":null,"network_id":null,"perMinuteCurrent":0,"perMinuteLimit":10,
        "perMonthCurrent":34,"perMonthLimit":2000,"tower1":{"phone_type":"GSM","psc":0,
        "cid":13564400,"lac":20601,"est_lat":"59.90981531125","est_lng":"10.77598607375",
        "est_acc":"236.7925","est_stddev":"0.25","2G":0,"3G":1,"4G":0,"network_id_main":2420,
        "network_ids_json_out":"NULL"}};

    before(function(){
      nock('http://api.opensignal.com')
        .get(/v2\/towerinfo\.json\?cid=\d+&lac=\d+&apikey=\w+$/)
        .reply(200, JSON.stringify(api_resp));
    });

    it("converts {cid, lac} into {lat,lng}", function(done) {

      cell2coords({cid: 13564400, lac: 20601}, function(error, coords) {
        should.not.exist(error);
        coords.lat.should.equal('59.90981531125');
        coords.lng.should.equal('10.77598607375');

        done();
      });

    });

  });

  describe("Handle HTTP errors", function() {

    before(function(){
      nock('http://api.opensignal.com')
      .get(/./g)
      .reply(404, 'This page could not be found');
    });

    it("propagates error from HTTP 404", function(done) {

      cell2coords({cid: 1234, lac: 5678}, function(error, coords) {
        should.exist(error);
        error.should.be.an('Error');
        error.message.should.equal('API call returned status code 404');

        done();
      });

    });

  });

});
{'fraction_non_alphanumeric': 0.2104393789230261, 'fraction_numerical': 0.0931615460852329, 'mean_word_length': 3.7238689547581902, 'pattern_counts': {'":': 48, '<': 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': '105985', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1069, 'n_words': 138}