From 2928e3e51522ef81ad4dfaed935d415eb8e6186d Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Mon, 13 May 2019 21:41:37 -0500 Subject: [PATCH] Add test for adjustment method 1 --- routes/weather.spec.ts | 12 ++++++++++++ test/expected.json | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/routes/weather.spec.ts b/routes/weather.spec.ts index 94d9c46..e18952d 100644 --- a/routes/weather.spec.ts +++ b/routes/weather.spec.ts @@ -22,6 +22,18 @@ describe('Watering Data', () => { await getWateringData(expressMocks.request, expressMocks.response); expect( expressMocks.response._getJSON() ).to.eql( expected.noWeather[location] ); }); + + it('OpenWeatherMap Lookup (Adjustment Method 1, Location 01002)', async () => { + nock( 'http://api.openweathermap.org' ) + .filteringPath( function() { return "/"; } ) + .get( "/" ) + .reply( 200, replies[location].OWMData ); + + + const expressMocks = createExpressMocks(1, location); + await getWateringData(expressMocks.request, expressMocks.response); + expect( expressMocks.response._getJSON() ).to.eql( expected.adjustment1[location] ); + }); }); function createExpressMocks(method: number, location: string) { diff --git a/test/expected.json b/test/expected.json index da0fe06..07816b5 100644 --- a/test/expected.json +++ b/test/expected.json @@ -14,5 +14,21 @@ "raining": 1 } } + }, + "adjustment1": { + "01002": { + "scale": 0, + "rd": -1, + "tz": 32, + "sunrise": 332, + "sunset": 1203, + "eip": 2130706433, + "rawData": { + "h": 98.5, + "p": 1.09, + "t": 70.8, + "raining": 1 + } + } } }