Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(packages/tuono-router): improve test using mocks #641

Merged
merged 4 commits into from
Mar 11, 2025

Conversation

marcalexiei
Copy link
Collaborator

Checklist

Related issue

Follow up of #633 (review)

Overview

  • uniform comonent style title ("Test ComponentName Component" → "< ComponentName />")
  • packages/tuono-router/src/components/Link.spec.tsx
    • add missing cleanup function
  • packages/tuono-router/src/components/NotFound.spec.tsx
    • use vi.mocked instead of mock + vi.hoised
    • mock components and hooks directly used by NotFound.spec.tsx
    • replaced snapshots checks with mock checks to ensure component is working correctly
    • In order to have a consistent test system checks I created NotFoundDefaultContent instead of using snapshots or rtl checks
  • packages/tuono-router/src/components/RouteMatch.spec.tsx
    • simplify createRouteComponent function
  • packages/tuono-router/src/hooks/useRoute.spec.ts
    • use vi.mocked instead of mock + vi.hoised
    • remove redundant check on current route

@marcalexiei marcalexiei self-assigned this Mar 10, 2025
@github-actions github-actions bot added the typescript Requires typescript knowledge label Mar 10, 2025
@marcalexiei marcalexiei marked this pull request as ready for review March 10, 2025 04:37
Copy link
Member

@Valerioageno Valerioageno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marcalexiei marcalexiei merged commit bfd0041 into main Mar 11, 2025
29 checks passed
@marcalexiei marcalexiei deleted the unit-test-improvements branch March 11, 2025 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Requires typescript knowledge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants