const sinon = require('sinon');
const expect = require('chai').expect;
const assert = require('chai').assert;
const needle = require('needle');

const config = require('../config');
const weather = require('../lib/weather');
describe('Weather information retrieval', function () {
  it('should retrieve weather info description if key, city and country are correct', function(){
      sinon.stub(needle, "get", function(){
          return {
              "weather": [
                  {
                      "description": "shower rain",
                  }
              ]
          }
      });
      var req = {
        query:{
            city:'city',
            country:'country'
        },
      };
      var res = {send: function(){}};
      var send = sinon.spy(res, "send");
      process.env.API_KEY = 'API_KEY';
      weather.getWeatherInfo(req, res);
      //actually a test of the getOpenWeatherUrl function
      expect(needle.get.getCall(0).args[0]).to.equal('http://api.openweathermap.org/data/2.5/weather?appid=API_KEY&q=city,country');
  });
});
@@ -644,20 +644,25 @@
   city:'
-city
+melbourne
 ',%0A     
@@ -677,23 +677,18 @@
 ountry:'
-country
+au
 '%0A      
@@ -1038,29 +1038,1370 @@
 Y&q=
-city,country');%0A  %7D);
+melbourne,au');%0A  %7D);%0A    it('should return proper message for invalid country', function()%7B%0A        var req = %7B%0A            query:%7B%0A                city:'city',%0A                country:'aud'%0A            %7D,%0A        %7D;%0A        var res = %7Bstatus: function()%7B%7D,json: function()%7B%7D%7D;%0A        var json = sinon.spy(res, %22json%22);%0A        var status = sinon.spy(res, %22status%22);%0A        process.env.API_KEY = 'API_KEY';%0A        weather.getWeatherInfo(req, res);%0A        expect(res.status.args%5B0%5D).to.deep.equal(%5B400%5D);%0A        expect(res.json.args%5B0%5D).to.deep.equal(%5B%7B%0A            %22status%22: %22400%22,%0A            %22message%22: %22Invalid country aud- pass two character ISO-3166 code%22%0A        %7D%5D);%0A    %7D);%0A    it('should return proper message for invalid city', function()%7B%0A        var req = %7B%0A            query:%7B%0A                city:'wrong-city',%0A                country:'au'%0A            %7D,%0A        %7D;%0A        var res = %7Bstatus: function()%7B%7D,json: function()%7B%7D%7D;%0A        var json = sinon.spy(res, %22json%22);%0A        var status = sinon.spy(res, %22status%22);%0A        process.env.API_KEY = 'API_KEY';%0A        weather.getWeatherInfo(req, res);%0A        expect(res.status.args%5B0%5D).to.deep.equal(%5B400%5D);%0A        expect(res.json.args%5B0%5D).to.deep.equal(%5B%7B%0A            %22status%22: %22400%22,%0A            %22message%22: %22Invalid city wrong-city- pass the full name of a city in AU%22%0A        %7D%5D);%0A    %7D);%0A
 %0A%7D);

Add tests for city and country validation