Skip to content

test(COMPT-33): consolidate all hook tests into src/hooks/__tests__/#10

Merged
a-elkhiraooui-ciscode merged 1 commit intodevelopfrom
feat/COMPT-33-test-suite
Mar 30, 2026
Merged

test(COMPT-33): consolidate all hook tests into src/hooks/__tests__/#10
a-elkhiraooui-ciscode merged 1 commit intodevelopfrom
feat/COMPT-33-test-suite

Conversation

@a-elkhiraooui-ciscode
Copy link
Copy Markdown

  • Move useDebounce, useLocalStorage, useSessionStorage, useMediaQuery, useWindowSize, useClickOutside, useIntersectionObserver tests to tests/
  • Update relative imports from ./ to ../
  • All 12 hooks covered: fake timers for debounce/interval/timeout/windowSize, mock matchMedia, mock IntersectionObserver, storage parse-error guards
  • 55 tests passing, 97.44% line coverage (>= 85% AC)

Summary

  • What does this PR change?

Why

  • Why is this change needed?

Checklist

  • Added/updated tests (if behavior changed)
  • npm run lint passes
  • npm run typecheck passes
  • npm test passes
  • npm run build passes
  • Added a changeset (npx changeset) if this affects consumers

Notes

  • Anything reviewers should pay attention to?

- Move useDebounce, useLocalStorage, useSessionStorage, useMediaQuery,
  useWindowSize, useClickOutside, useIntersectionObserver tests to __tests__/
- Update relative imports from ./ to ../
- All 12 hooks covered: fake timers for debounce/interval/timeout/windowSize,
  mock matchMedia, mock IntersectionObserver, storage parse-error guards
- 55 tests passing, 97.44% line coverage (>= 85% AC)
Copilot AI review requested due to automatic review settings March 30, 2026 13:57
@sonarqubecloud
Copy link
Copy Markdown

@a-elkhiraooui-ciscode a-elkhiraooui-ciscode merged commit 1eeeaaa into develop Mar 30, 2026
4 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates hook test files under src/hooks/__tests__/ and updates test imports accordingly, while documenting the new test layout and adding a changeset entry for COMPT-33.

Changes:

  • Update hook test imports to reference hook modules via ../ after moving tests into src/hooks/__tests__/.
  • Update repo instructions to document the consolidated hook test location and COMPT-33 status.
  • Add a Changesets entry describing the consolidated test suite and coverage expectations.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/hooks/tests/useWindowSize.test.ts Updates import path for useWindowSize/getWindowSize after test relocation.
src/hooks/tests/useSessionStorage.test.ts Updates import paths for useSessionStorage and storage helper.
src/hooks/tests/useMediaQuery.test.ts Updates import path for useMediaQuery after test relocation.
src/hooks/tests/useLocalStorage.test.ts Updates import paths for useLocalStorage and storage helper.
src/hooks/tests/useIntersectionObserver.test.ts Updates import path for useIntersectionObserver after test relocation.
src/hooks/tests/useDebounce.test.ts Updates import path for useDebounce after test relocation.
src/hooks/tests/useClickOutside.test.ts Updates import path for useClickOutside after test relocation.
.github/instructions/copilot-instructions.md Documents COMPT-33 test consolidation and updates module structure listing.
.changeset/COMPT-33-test-suite.md Adds release note for COMPT-33 test suite consolidation and coverage goals.

Comment on lines 20 to 24
- **State & Storage** (COMPT-30 ✅) — `useDebounce`, `useLocalStorage`, `useSessionStorage`
- **DOM & Events** (COMPT-31 ✅) — `useMediaQuery`, `useWindowSize`, `useClickOutside`, `useIntersectionObserver`
<<<<<<< HEAD
- **Async & Lifecycle** (COMPT-32 ✅) — `usePrevious`, `useToggle`, `useInterval`, `useTimeout`, `useIsFirstRender`
- **Test Suite** (COMPT-33 ✅) — Full coverage for all 12 hooks, all tests in `src/hooks/__tests__/`

Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The docs state the package provides/tests “all 12 hooks”, but the public exports include an additional hook (useNoop) via src/hooks/index.ts (and re-exported from src/index.ts). Either update the docs/count to include useNoop (and its test location), or stop exporting it if it’s not meant to be part of the public hook surface.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +11
- Consolidate all hook tests under src/hooks/__tests__/
- Cover all 12 hooks: useDebounce, useLocalStorage, useSessionStorage,
useMediaQuery, useWindowSize, useClickOutside, useIntersectionObserver,
usePrevious, useToggle, useInterval, useTimeout, useIsFirstRender
- Use vitest fake timers for useDebounce, useInterval, useTimeout, useWindowSize
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This release note says the test suite covers “all 12 hooks”, but the package currently exports another hook (useNoop) publicly. Please either include useNoop in this list/coverage statement, or adjust exports so the “12 hooks” claim is accurate.

Copilot uses AI. Check for mistakes.
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.

2 participants