From 54d830ad144670a64ee22d90bbf488f50c9530d8 Mon Sep 17 00:00:00 2001 From: Justin Stayton Date: Thu, 27 Aug 2026 06:42:48 -0400 Subject: [PATCH] Rename leeway tests after the scenario they cover MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old names described a direction that reads backwards. Setting the clock to `sentAtMs + 5min` puts the receipt time after the signed timestamp — the webhook arrived late — but that test was named for the "future" leeway window, and its error-case twin read "the timestamp is outside the future leeway window" while firing on a timestamp in the past. Naming them after the scenario drops the frame of reference entirely, so there's nothing left to get backwards. The assertions are unchanged. Co-Authored-By: Claude Opus 5 --- src/main.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.test.js b/src/main.test.js index c3868c9..3095c15 100644 --- a/src/main.test.js +++ b/src/main.test.js @@ -32,7 +32,7 @@ describe('verifyTruepicWebhook', () => { }) describe('timestamp leeway window', () => { - it('accepts a timestamp exactly at the future leeway window', (t) => { + it('accepts a webhook that arrives exactly 5 minutes late', (t) => { t.mock.timers.enable({ apis: ['Date'], now: sentAtMs + 1000 * 60 * 5, @@ -50,7 +50,7 @@ describe('verifyTruepicWebhook', () => { ) }) - it('accepts a timestamp exactly at the past leeway window', (t) => { + it('accepts a webhook whose sender clock is exactly 5 minutes ahead', (t) => { t.mock.timers.enable({ apis: ['Date'], now: sentAtMs - 1000 * 60 * 5, @@ -200,7 +200,7 @@ describe('verifyTruepicWebhook', () => { ) }) - it('if the timestamp is outside the future leeway window', (t) => { + it('if the webhook arrives more than 5 minutes late', (t) => { t.mock.timers.enable({ apis: ['Date'], now: sentAtMs + 1000 * 60 * 5 + 1, @@ -221,7 +221,7 @@ describe('verifyTruepicWebhook', () => { ) }) - it('if the timestamp is outside the past leeway window', (t) => { + it('if the sender clock is more than 5 minutes ahead', (t) => { t.mock.timers.enable({ apis: ['Date'], now: sentAtMs - 1000 * 60 * 5 - 1,