From d832c61f0b7cdb5511a270683878eafc3308286a Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Sun, 12 Jul 2015 15:54:50 -0500 Subject: [PATCH] Add ability to test against Weather Underground --- test/api.js | 37 ++++++++++++++++++++++++++++++++++--- test/expected.json | 36 +++++++++++++++++++++++++++++------- 2 files changed, 63 insertions(+), 10 deletions(-) diff --git a/test/api.js b/test/api.js index 278ee2a..a132faa 100644 --- a/test/api.js +++ b/test/api.js @@ -8,12 +8,43 @@ var hippie = require( "hippie" ), describe( "Weather API", function() { describe( "/:method endpoint", function() { it( "The Weather Channel Source Test", function( done ) { - for ( var test in expected ) { - if ( expected.hasOwnProperty( test ) ) { + for ( var test in expected.WSI ) { + if ( expected.WSI.hasOwnProperty( test ) ) { apiTest( { method: 1, loc: test, - expected: expected[test], + expected: expected.WSI[test], + callback: function( reply ) { + done(); + } + } ); + } + } + } ); + + it( "Weather Underground Source Test", function( done ) { + for ( var test in expected.WU ) { + if ( expected.WU.hasOwnProperty( test ) ) { + apiTest( { + method: 1, + loc: test, + key: process.env.WU_API_KEY, + expected: expected.WU[test], + callback: function( reply ) { + done(); + } + } ); + } + } + } ); + + it( "Information lookup without weather lookup", function( done ) { + for ( var test in expected.noWeather ) { + if ( expected.noWeather.hasOwnProperty( test ) ) { + apiTest( { + method: 0, + loc: test, + expected: expected.noWeather[test], callback: function( reply ) { done(); } diff --git a/test/expected.json b/test/expected.json index 23656b9..4d53ab5 100644 --- a/test/expected.json +++ b/test/expected.json @@ -1,10 +1,32 @@ { - "01002": { - "scale": 83, - "restrict": 0, - "tz": 32, - "sunrise": 324, - "sunset": 1226, - "eip": 2130706433 + "WSI": { + "01002": { + "scale": 83, + "restrict": 0, + "tz": 32, + "sunrise": 324, + "sunset": 1226, + "eip": 2130706433 + } + }, + "WU": { + "01002": { + "scale": 61, + "restrict": 0, + "tz": 32, + "sunrise": 324, + "sunset": 1228, + "eip": 2130706433 + } + }, + "noWeather": { + "01002": { + "scale": -1, + "restrict": 0, + "tz": 32, + "sunrise": 324, + "sunset": 1226, + "eip": 2130706433 + } } }