test(query-core/subscribable): add unit tests for the Subscribable base class - #11364
test(query-core/subscribable): add unit tests for the Subscribable base class#11364solssak wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughAdded a new ChangesSubscribable listener lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change adds focused tests for existing subscription behavior without modifying production code or runtime behavior. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No 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 files. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
🎯 Changes
Add a dedicated unit test file for the
Subscribablebase class inquery-core.Subscribableis the base class thatQueryCache,MutationCache,QueryObserver,MutationObserver,QueriesObserver,FocusManager, andOnlineManagerall extend, but it had no test file of its own — its behavior was only exercised indirectly through those subclasses. This PR tests the class directly so the core subscribe/unsubscribe contract is pinned down in one place.The new
subscribable.test.tsxuses a minimal test subclass that spies on the protectedonSubscribe/onUnsubscribehooks, and covers:onSubscribefires once persubscribe()callonUnsubscribefires when the returned unsubscribe function is calledhasListeners()transitions correctly across subscribe/unsubscribe, including when multiple listeners are registered and only some unsubscribeSetsemantics)subscribemethod stays bound to the instance when destructured (thethis.subscribe = this.subscribe.bind(this)in the constructor)No source code is changed — this only adds test coverage.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit