Consolidate OWM mocks
This commit is contained in:
@@ -12,11 +12,7 @@ const location = '01002';
|
|||||||
|
|
||||||
describe('Watering Data', () => {
|
describe('Watering Data', () => {
|
||||||
it('OpenWeatherMap Lookup (Adjustment Method 0, Location 01002)', async () => {
|
it('OpenWeatherMap Lookup (Adjustment Method 0, Location 01002)', async () => {
|
||||||
nock( 'http://api.openweathermap.org' )
|
mockOWM();
|
||||||
.filteringPath( function() { return "/"; } )
|
|
||||||
.get( "/" )
|
|
||||||
.reply( 200, replies[location].OWMData );
|
|
||||||
|
|
||||||
|
|
||||||
const expressMocks = createExpressMocks(0, location);
|
const expressMocks = createExpressMocks(0, location);
|
||||||
await getWateringData(expressMocks.request, expressMocks.response);
|
await getWateringData(expressMocks.request, expressMocks.response);
|
||||||
@@ -24,11 +20,7 @@ describe('Watering Data', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('OpenWeatherMap Lookup (Adjustment Method 1, Location 01002)', async () => {
|
it('OpenWeatherMap Lookup (Adjustment Method 1, Location 01002)', async () => {
|
||||||
nock( 'http://api.openweathermap.org' )
|
mockOWM();
|
||||||
.filteringPath( function() { return "/"; } )
|
|
||||||
.get( "/" )
|
|
||||||
.reply( 200, replies[location].OWMData );
|
|
||||||
|
|
||||||
|
|
||||||
const expressMocks = createExpressMocks(1, location);
|
const expressMocks = createExpressMocks(1, location);
|
||||||
await getWateringData(expressMocks.request, expressMocks.response);
|
await getWateringData(expressMocks.request, expressMocks.response);
|
||||||
@@ -56,4 +48,11 @@ function createExpressMocks(method: number, location: string) {
|
|||||||
request
|
request
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockOWM() {
|
||||||
|
nock( 'http://api.openweathermap.org' )
|
||||||
|
.filteringPath( function() { return "/"; } )
|
||||||
|
.get( "/" )
|
||||||
|
.reply( 200, replies[location].OWMData );
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user