Skip to main content

test: cover normal behavior and edge cases

GBB Demo authored on Nov 2, 2026

parent 6074254commit 829462ce031c

2 files changed, +21 −0

  • package.json+9 −0
    @@ -1,0 +1,9 @@
    1+{
    2+ "name": "webhook-lab",
    3+ "version": "0.1.0",
    4+ "private": true,
    5+ "type": "module",
    6+ "scripts": {
    7+ "test": "node test.mjs"
    8+ }
    9+}
  • test.mjs+12 −0
    @@ -1,0 +1,12 @@
    1+import assert from "node:assert/strict";
    2+import * as app from "./app.mjs";
    3+
    4+const fixtureKey = "synthetic-test-fixture";
    5+const payload = '{"event":"demo.created"}';
    6+const signature = app.sign(payload, fixtureKey);
    7+assert.equal(app.verify(payload, signature, fixtureKey), true);
    8+assert.equal(app.verify(payload + " ", signature, fixtureKey), false);
    9+assert.equal(app.verify(payload, "malformed", fixtureKey), false);
    10+assert.equal(app.verify(payload, signature, "different-fixture"), false);
    11+
    12+console.log("All checks passed");