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