Fix unit tests by mocking the date
This commit is contained in:
5
package-lock.json
generated
5
package-lock.json
generated
@@ -2377,6 +2377,11 @@
|
||||
"integrity": "sha1-mDaL6wnfdT9k9m2U5VNql7NqJDA=",
|
||||
"dev": true
|
||||
},
|
||||
"mockdate": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/mockdate/-/mockdate-2.0.2.tgz",
|
||||
"integrity": "sha1-WuDA6vj+I+AJzQH5iJtCxPY0rxI="
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.24.0",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"dotenv": "^8.0.0",
|
||||
"express": "^4.16.4",
|
||||
"geo-tz": "^5.0.4",
|
||||
"mockdate": "^2.0.2",
|
||||
"moment-timezone": "^0.5.25",
|
||||
"suncalc": "^1.8.0"
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ import { expect } from 'chai';
|
||||
import * as nock from 'nock';
|
||||
import * as MockExpressRequest from 'mock-express-request';
|
||||
import * as MockExpressResponse from 'mock-express-response';
|
||||
import * as MockDate from 'mockdate';
|
||||
|
||||
import { getWateringData } from './weather';
|
||||
|
||||
@@ -11,6 +12,8 @@ const replies = require( '../test/replies.json' );
|
||||
const location = '01002';
|
||||
|
||||
describe('Watering Data', () => {
|
||||
beforeEach(() => MockDate.set('5/13/2019'));
|
||||
|
||||
it('OpenWeatherMap Lookup (Adjustment Method 0, Location 01002)', async () => {
|
||||
mockOWM();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user