Skip to content
Source
Sign inSign up
TanStack/store

test(store): add unit tests for shallow equality utility #393

Closedgrzdev(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/393/headopened

🎯 Changes

Adds a dedicated unit test suite for the shallow equality helper in @tanstack/store (packages/store/src/shallow.ts), covering:

  • Primitive values, NaN, null, undefined, and identical references
  • Mismatched primitives and null/object boundaries
  • Shallow object comparisons (including property additions and differing values)
  • Symbol keys in object property comparisons
  • Arrays and length differences
  • Map instances (differing sizes and values)
  • Set instances (differing sizes and items)
  • Date instances

✅ Checklist

  • I have read the contributing guide
  • Tests pass locally (pnpm --filter @tanstack/store run test:lib)
  • ESLint passes locally (pnpm --filter @tanstack/store run test:eslint)
  • TypeScript type checks pass locally (pnpm --filter @tanstack/store run test:types)

🚀 Release Impact

  • Published package changes (requires changeset)
  • Tests / CI / Dev only

Summary by CodeRabbit

  • Tests
    • Added coverage for shallow comparisons across primitive values, references, objects, arrays, collections, and dates.
    1. changeset-bot[bot](GitHub profile, opens in a new tab)commented

      ⚠️ No Changeset found

      Latest commit: 2e5afb7d896733dbd4d2d556ec07a74d8a4163a0

      Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

      This PR includes no changesets

      When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

      Click here to learn what changesets are, and how to add one.

      Click here if you're a maintainer who wants to add a changeset to this PR

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Important

      Review skipped

      Review was skipped as selected files did not have any reviewable changes.

      ⚙️ Run configuration
      • Configuration used: Repository: TanStack/store/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 85753fcd-19d4-479f-b8e8-4955f410d233
      📥 Commits

      Reviewing files that changed from the base of the PR and between d6f288221d3550ca1a6302c6b6e11875287f36e6 and 2e5afb7d896733dbd4d2d556ec07a74d8a4163a0.

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Repository: TanStack/store/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: d508cda8-ca53-492f-98a5-04f8c3c034d2
      📥 Commits

      Reviewing files that changed from the base of the PR and between 51ddb30396dd01d10dcab50a0a3a5f4d7afb72d3 and d6f288221d3550ca1a6302c6b6e11875287f36e6.

      📒 Files selected for processing (1)
      • packages/store/tests/shallow.test.ts

      Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

      📝 Walkthrough

      Walkthrough

      Added Vitest coverage for shallow comparisons across primitives, references, objects, arrays, Maps, Sets, and Dates.

      Changes

      Shallow comparison test coverage

      Layer / File(s)Summary
      Shallow comparison cases
      packages/store/tests/shallow.test.ts
      Added equality and inequality cases for primitive values, references, plain objects, symbol-keyed properties, arrays, Maps, Sets, and Dates.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Other

      Merge Risk: ⚪ Minimal · up to d6f28

      The change adds shallow-equality tests without an identified merge-blocking issue.

      Pre-merge checks | Passed 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Description checkPassedThe description explains the test coverage, records local validation, and identifies the change as tests-only. It includes all required sections. It does not explicitly confirm understanding of AI-ass…
      Title checkPassedThe title clearly and concisely describes the main change: adding unit tests for the store shallow equality utility.
      Docstring CoveragePassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    3. TkDodo closed this

Sign in to join this conversation.