From c26aacacf50b52ff94cc349a49f19f41aff20a25 Mon Sep 17 00:00:00 2001 From: Steve Larson <9larsons@gmail.com> Date: Wed, 2 Oct 2024 12:54:48 -0500 Subject: [PATCH] Fixed Date.now() use in email analytics unit tests (#21188) no ref We had an instance where this was a ms off and I should've used mock timers when I first wrote this. This should prevent any rare clock mishaps. --- .../test/email-analytics-service.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ghost/email-analytics-service/test/email-analytics-service.test.js b/ghost/email-analytics-service/test/email-analytics-service.test.js index 66a42237787..404ab48ce01 100644 --- a/ghost/email-analytics-service/test/email-analytics-service.test.js +++ b/ghost/email-analytics-service/test/email-analytics-service.test.js @@ -10,6 +10,16 @@ const { const EventProcessingResult = require('../lib/EventProcessingResult'); describe('EmailAnalyticsService', function () { + let clock; + + beforeEach(function () { + clock = sinon.useFakeTimers(new Date(2024, 0, 1)); + }); + + afterEach(function () { + clock.restore(); + }); + describe('getStatus', function () { it('returns status object', function () { // these are null because we're not running them before calling this