Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cron/mergeRenovatePRs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,19 @@ describe('mergeRenovatePRs', () => {
});

it('should not merge on Tuesdays', async () => {
jest.useFakeTimers({ now: new Date('2022-06-28T00:00:00.000Z') });
// NOTE: This test would previously pass/fail based on the phystical
// location where it was run.
// Example: Midnight UTC is 7pm CDT on the previous day
//
// To fix this, we adjust the generated date by the timezone offset
const desiredDate = new Date('2022-06-28T00:00:00.000Z');
const ONE_EARTH_MINUTE = 60_000;
jest.useFakeTimers({
now: new Date(
desiredDate.getTime() +
desiredDate.getTimezoneOffset() * ONE_EARTH_MINUTE,
),
});

await mergeRenovatePRs(client, repoInfo, log, 0);
expect(mockClient.rest.pulls.merge).not.toHaveBeenCalled();
Expand Down
Loading