From 9275abde276f58c6acbfc8c51eab046530007a3e Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Mon, 13 May 2019 21:38:45 -0500 Subject: [PATCH] Improve categories for tests --- routes/weather.spec.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/routes/weather.spec.ts b/routes/weather.spec.ts index 3a24dd7..94d9c46 100644 --- a/routes/weather.spec.ts +++ b/routes/weather.spec.ts @@ -10,30 +10,29 @@ const replies = require( '../test/replies.json' ); const location = '01002'; -describe('/:method endpoint', () => { - beforeEach(() => { +describe('Watering Data', () => { + it('OpenWeatherMap Lookup (Adjustment Method 0, Location 01002)', async () => { nock( 'http://api.openweathermap.org' ) .filteringPath( function() { return "/"; } ) .get( "/" ) .reply( 200, replies[location].OWMData ); - }); - it('Information lookup without weather lookup', async () => { - const expressMocks = createExpressMocks(location); + + const expressMocks = createExpressMocks(0, location); await getWateringData(expressMocks.request, expressMocks.response); expect( expressMocks.response._getJSON() ).to.eql( expected.noWeather[location] ); }); }); -function createExpressMocks(location: string) { +function createExpressMocks(method: number, location: string) { const request = new MockExpressRequest({ method: 'GET', - url: '/0?loc=' + location, + url: `/${method}?loc=${location}`, query: { loc: location, format: 'json' }, - params: [ 0 ], + params: [ method ], headers: { 'x-forwarded-for': '127.0.0.1' }