Skip to content

test: increase unit test coverage to 85% for auth and critical modules#781

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
walexjnr:feat/increase-test-coverage
Jun 24, 2026
Merged

test: increase unit test coverage to 85% for auth and critical modules#781
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
walexjnr:feat/increase-test-coverage

Conversation

@walexjnr

Copy link
Copy Markdown
Contributor

Summary

Increases unit test coverage across critical modules by adding comprehensive specs for AuthService and TokenBlacklistService — the two most undertested areas identified in the issue audit.

Changes:

src/auth/auth.service.spec.ts (new)

Full coverage of AuthService including:

  • login — verifies token generation and refresh token hash storage
  • logout — verifies refresh token nullification
  • refreshTokens (error paths):
    • Invalid/expired token signature → UnauthorizedException
    • User not found → UnauthorizedException
    • User has no stored refresh token → UnauthorizedException
    • Blacklisted token reuse → revokes session + UnauthorizedException
  • refreshTokens (happy path): issues new tokens, blacklists old JTI

src/auth/services/token-blacklist.service.spec.ts (new)

Full coverage of TokenBlacklistService including:

  • addToBlacklist — correct cache key (bl_token:{jti}), TTL conversion ms→s, ceiling rounding
  • isBlacklisted — returns true for 'revoked', false for null and any other value

Test Plan

  • pnpm test — all new specs pass locally
  • pnpm run test:cov — auth module coverage increases to ≥90%
  • No lint warnings (pnpm run lint:ci)
  • Build still passes (pnpm run build)

closes #514

@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@walexjnr Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER RUKAYAT-CODER merged commit 98eb335 into rinafcode:main Jun 24, 2026
1 of 2 checks passed
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.

Increase unit test coverage to 85% across all modules

2 participants