Skip to content

feat: add toast component unit tests - #632

Merged
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
Stanley-Owoh:add-toast-component-unit-tests-628
Jul 28, 2026
Merged

feat: add toast component unit tests#632
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
Stanley-Owoh:add-toast-component-unit-tests-628

Conversation

@Stanley-Owoh

Copy link
Copy Markdown
Contributor

Add unit tests for toast component auto-dismiss and manual close

Summary

Added unit tests for showToast.success() confirming both the auto-dismiss timing and manual close behavior work correctly.

Changes

  • New file: src/utils/__tests__/toast.util.test.tsx

Tests added

Test Assertion
Toast visible immediately after render getByText('Success message') is in the document
Toast still visible at 3999ms After advanceTimersByTime(3999), toast remains in the DOM
Toast removed after auto-dismiss + remove delay After advancing past 4000ms (dismiss) + 1000ms (REMOVE_DELAY), toast is removed from the DOM
Manual close removes toast before auto-dismiss Calling toast.dismiss() removes the toast immediately without waiting for the timer

Notes

  • Tests use vi.useFakeTimers() with a matchMedia mock required by react-hot-toast's <Toaster> component
  • The <Toaster> from react-hot-toast is rendered directly in tests (not the app's <Toaster> from App.tsx) to isolate the toast utility
  • react-hot-toast uses a two-phase removal: dismiss (sets visible: false) then a REMOVE_DELAY of 1000ms before unmounting from the DOM

Closes #628

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@Stanley-Owoh 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

@Chucks1093
Chucks1093 merged commit da0b96e into accesslayerorg:dev Jul 28, 2026
1 check 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.

Add unit tests for the toast component confirming auto-dismiss timing and manual close

2 participants