Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+31
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { decideWebhookRenewal, DEFAULT_RENEWAL_THRESHOLD_MS } from "./calendar-webhook-renewal.js";
|
||||
|
||||
const now = new Date("2026-07-01T12:00:00Z");
|
||||
|
||||
describe("decideWebhookRenewal", () => {
|
||||
it("renews when there is no subscription yet", () => {
|
||||
expect(decideWebhookRenewal({ expiresAt: null, now })).toEqual({ shouldRenew: true, reason: "no_subscription" });
|
||||
});
|
||||
|
||||
it("renews when expiring within the threshold", () => {
|
||||
const expiresAt = new Date(now.getTime() + DEFAULT_RENEWAL_THRESHOLD_MS - 60_000);
|
||||
expect(decideWebhookRenewal({ expiresAt, now })).toEqual({ shouldRenew: true, reason: "expiring_soon" });
|
||||
});
|
||||
|
||||
it("renews exactly at the threshold boundary", () => {
|
||||
const expiresAt = new Date(now.getTime() + DEFAULT_RENEWAL_THRESHOLD_MS);
|
||||
expect(decideWebhookRenewal({ expiresAt, now }).shouldRenew).toBe(true);
|
||||
});
|
||||
|
||||
it("leaves a still-valid subscription alone", () => {
|
||||
const expiresAt = new Date(now.getTime() + DEFAULT_RENEWAL_THRESHOLD_MS + 60 * 60_000);
|
||||
expect(decideWebhookRenewal({ expiresAt, now })).toEqual({ shouldRenew: false, reason: "still_valid" });
|
||||
});
|
||||
|
||||
it("honours a custom threshold", () => {
|
||||
const expiresAt = new Date(now.getTime() + 2 * 60 * 60_000); // 2h left
|
||||
expect(decideWebhookRenewal({ expiresAt, now, thresholdMs: 60 * 60_000 }).shouldRenew).toBe(false);
|
||||
expect(decideWebhookRenewal({ expiresAt, now, thresholdMs: 3 * 60 * 60_000 }).shouldRenew).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user