Skip to content

Commit 9bbb414

Browse files
committed
Fix unit tests by mocking the date
1 parent e28c309 commit 9bbb414

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"dotenv": "^8.0.0",
1717
"express": "^4.16.4",
1818
"geo-tz": "^5.0.4",
19+
"mockdate": "^2.0.2",
1920
"moment-timezone": "^0.5.25",
2021
"suncalc": "^1.8.0"
2122
},

routes/weather.spec.ts

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expect } from 'chai';
22
import * as nock from 'nock';
33
import * as MockExpressRequest from 'mock-express-request';
44
import * as MockExpressResponse from 'mock-express-response';
5+
import * as MockDate from 'mockdate';
56

67
import { getWateringData } from './weather';
78

@@ -11,6 +12,8 @@ const replies = require( '../test/replies.json' );
1112
const location = '01002';
1213

1314
describe('Watering Data', () => {
15+
beforeEach(() => MockDate.set('5/13/2019'));
16+
1417
it('OpenWeatherMap Lookup (Adjustment Method 0, Location 01002)', async () => {
1518
mockOWM();
1619

0 commit comments

Comments
 (0)