Skip to content
Source
Sign inSign up
TanStack/store

test(store): add coverage for store get method and bound destructuring #394

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

🎯 Changes

Adds unit tests covering the get() getter method across both Store and ReadonlyStore in @tanstack/store (packages/store/src/store.ts):

  • Validates Store.prototype.get() returns the current state value
  • Verifies method context remains bound upon destructuring alongside setState
  • Validates ReadonlyStore.prototype.get() accurately reflects derived computations following base store state updates

✅ 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 confirming that store reads return the latest state and remain available after destructuring, including for derived stores.
    1. changeset-bot[bot](GitHub profile, opens in a new tab)commented

      ⚠️ No Changeset found

      Latest commit: 8f3ee9e9a208156be3991a89efcbc754c87432f7

      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: 5dc2576d-81de-49ad-86bc-c6bf5537133a
      📥 Commits

      Reviewing files that changed from the base of the PR and between 4178a98b5371ec10726c1068cb7d3ca52724c562 and 8f3ee9e9a208156be3991a89efcbc754c87432f7.

      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: eeb72fde-9c0c-4b04-8312-71c884ac728a
      📥 Commits

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

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

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

      📝 Walkthrough

      Walkthrough

      The change adds tests for writable store get() behavior, including after destructuring and state updates, and for derived store get() values before and after base store updates.

      Changes

      Store get() behavior

      Layer / File(s)Summary
      Writable and derived store get() tests
      packages/store/tests/store.test.ts
      Tests check that a destructured writable store get() returns the current value after setState, and that a derived store get() reflects changes to its base store.

      Priority: ⬇️ Low

      Estimated code review effort: 1 (Trivial) | ~5 minutes

      Change: Other

      Merge Risk: ⚪ Minimal · up to 4178a

      The tests cover the stated store get() behaviors, with no identified issue blocking merge.

      Pre-merge checks | Passed 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the main change: adding store tests for the get method and bound destructuring.
      Description checkPassedThe description includes all required sections, explains the test coverage and motivation, records local validation, and identifies the change as tests/CI/dev-only with no changeset required.
      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.