Files
Cato bd7f303ce6 chore(deps): web-push 4, which is an ES module with named exports (#296)
web-push 4.0.0 has no default export, so the build of #281 failed on
`import webpush from "web-push"`. The two calls are imported by name, and
a test loads the real module, because the type package still describes both
shapes and only the build noticed.

Claude-Session: https://claude.ai/code/session_019MDtmsubNtjznXC5pMf4fD
2026-11-10 15:21:08 +01:00

31 lines
1.1 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "node:test";
import { sendNotification, setVapidDetails } from "web-push";
import { pushConfigured, sendPush } from "./send.ts";
/**
* web-push 4 is an ES module with named exports and no default. The type
* package still describes both shapes, so only loading the real module says
* whether the two functions this file calls are there.
*/
test("the two web-push functions this module calls exist", () => {
assert.equal(typeof sendNotification, "function");
assert.equal(typeof setVapidDetails, "function");
});
test("without VAPID keys nothing is sent and nothing is called dead", async () => {
const saved = { ...process.env };
delete process.env.VAPID_PUBLIC_KEY;
delete process.env.VAPID_PRIVATE_KEY;
delete process.env.VAPID_SUBJECT;
try {
assert.equal(pushConfigured(), false);
assert.deepEqual(await sendPush({ endpoint: "https://push.example/x", p256dh: "k", auth: "a", locale: "en", actorId: "a1" }, { title: "t", body: "b", url: "/" } as never), {
ok: false,
dead: false,
});
} finally {
process.env = saved;
}
});