Skip to content

Test the remaining branches & guard the secret - #44

Merged
jstayton merged 1 commit into
developmentfrom
test/coverage-gaps
Aug 27, 2026
Merged

jstayton merged 1 commit into
developmentfrom
test/coverage-gaps

Conversation

@jstayton

Copy link
Copy Markdown
Contributor

Branch coverage sat at 87.88%, and mutation testing showed the gaps were real rather than cosmetic: changing the default leeway from 5 minutes to 60, or removing it outright, left all 19 tests green. So did dropping either empty-part check in the header parser. This adds the tests that close those gaps, plus a test file for the error class, taking both files to 100% line and branch coverage.

Two small source changes come with it. A missing secret threw a raw TypeError out of createHmac rather than the TruepicWebhookVerifierError that both the JSDoc and main.d.ts promise — the likely trigger being an unset env var — and a non-string header died on header.split. Both now throw the documented error.

That makes this a minor release rather than a patch: an empty secret now reports "Secret is missing or empty" where it previously reported "Signature is not valid". No existing message changed, and both paths failed closed before and after.

Deliberately left out: main.d.ts still isn't type-checked in CI, which is its own change.

🤖 Generated with Claude Code

Branch coverage sat at 87.88%. The empty comma-separated header parts,
the `indexOf('=') === -1` fallbacks in both halves of the header, and
the default leeway of 5 minutes all went unexercised. Mutation testing
turned up more: changing the default leeway to 60, or dropping it
outright, left the whole suite green.

A missing `secret` also threw a raw `TypeError` out of `createHmac`
rather than the `TruepicWebhookVerifierError` that the JSDoc and the
type declarations promise, and a non-string `header` died on
`header.split`. Both now throw the documented error, which means an
empty secret reports "Secret is missing or empty" where it used to
report "Signature is not valid". No existing message changed.

Coverage is now 100% line and branch across both files.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jstayton
jstayton merged commit f4fe6ab into development Aug 27, 2026
4 checks passed
@jstayton
jstayton deleted the test/coverage-gaps branch August 27, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant