From c5fa30ff2c9a4e5a0988422f894941c295268bca Mon Sep 17 00:00:00 2001 From: Jahred Hope <jahredhope@gmail.com> Date: Mon, 8 Jan 2018 23:39:42 +1100 Subject: [PATCH] test: use local times for tests (#1354) This change allows unit tests that don't set a timezone to refer to the local time. Closes #1353 --- test/workers/branch/schedule.spec.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/workers/branch/schedule.spec.js b/test/workers/branch/schedule.spec.js index b113748534..9bd78798ad 100644 --- a/test/workers/branch/schedule.spec.js +++ b/test/workers/branch/schedule.spec.js @@ -78,7 +78,7 @@ describe('workers/branch/schedule', () => { describe('isScheduledNow(config)', () => { let config; beforeEach(() => { - mockDate.set(1498812608678); // 2017-06-30 10:50am + mockDate.set('2017-06-30T10:50:00.000'); // Locally 2017-06-30 10:50am jest.resetAllMocks(); config = {}; }); @@ -114,6 +114,7 @@ describe('workers/branch/schedule', () => { it('supports timezone', () => { config.schedule = ['after 4:00pm']; config.timezone = 'Asia/Singapore'; + mockDate.set('2017-06-30T10:50:00.000Z'); // Globally 2017-06-30 10:50am const res = schedule.isScheduledNow(config); expect(res).toBe(true); }); @@ -159,7 +160,7 @@ describe('workers/branch/schedule', () => { }); it('approves first day of the month', () => { config.schedule = ['before 11am on the first day of the month']; - mockDate.set(1506835566000); // Sunday, 1 October 2017 05:26:06 + mockDate.set('2017-10-01T05:26:06.000'); // Locally Sunday, 1 October 2017 05:26:06 const res = schedule.isScheduledNow(config); expect(res).toBe(true); }); -- GitLab