Skip to content

test(lib): cover safeHref validation#210

Open
alan-provable wants to merge 1 commit into
Agentpay-Org:mainfrom
alan-provable:issue-144-safehref-tests
Open

test(lib): cover safeHref validation#210
alan-provable wants to merge 1 commit into
Agentpay-Org:mainfrom
alan-provable:issue-144-safehref-tests

Conversation

@alan-provable

Copy link
Copy Markdown

Closes #144

Summary

  • Consolidates safeHref coverage into table-driven accept/reject cases.
  • Covers uppercase HTTPS, root-relative links, hash links, dangerous schemes, protocol-relative URLs, nullish and blank inputs, bare words, missing-colon URLs, colon-at-index-zero inputs, mailto, tel, ftp, and obfuscated schemes.
  • Adds a 100 percent per-file Jest coverage threshold for src/lib/url.ts.
  • Adds missing imports in src/app/docs/page.tsx so current main can typecheck and lint after the recent docs-page changes.

Validation

  • npm run typecheck
  • npm run lint
  • npx eslint src/lib/url.ts src/lib/__tests__/url.test.ts jest.config.ts
  • npx jest src/lib/__tests__/url.test.ts --coverage --collectCoverageFrom=src/lib/url.ts --coverageThreshold='{"./src/lib/url.ts":{"statements":100,"branches":100,"functions":100,"lines":100}}'
    • 25 tests passed.
    • src/lib/url.ts reached 100 percent statements, branches, functions, and lines.
  • git diff --check origin/main..HEAD

Known Baseline

  • npm test still has 2 unrelated failures in untouched src/components/__tests__/Header.test.tsx; the suite otherwise reports 561 passing tests and 2 skipped tests.

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.

Add unit tests for the safeHref URL scheme validator

1 participant