test(solid-query/queryOptions): add runtime test for identity function behavior#10135
test(solid-query/queryOptions): add runtime test for identity function behavior#10135sukvvon wants to merge 2 commits intoTanStack:mainfrom
Conversation
|
📝 WalkthroughWalkthroughAdds a new Vitest unit test that asserts Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
|
View your CI Pipeline Execution ↗ for commit 29a4226
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/solid-query/src/__tests__/queryOptions.test.tsx`:
- Around line 6-12: The test currently uses toStrictEqual which allows clones to
pass; change the assertion to use reference equality so it verifies the same
object instance is returned—update the test in queryOptions.test.tsx to replace
expect(queryOptions(object)).toStrictEqual(object) with
expect(queryOptions(object)).toBe(object) so the queryOptions function's
identity contract (returning the same object) is correctly asserted.
| it('should return the object received as a parameter without any modification.', () => { | ||
| const object: SolidQueryOptions = { | ||
| queryKey: ['key'], | ||
| queryFn: () => Promise.resolve(5), | ||
| } as const | ||
|
|
||
| expect(queryOptions(object)).toStrictEqual(object) |
There was a problem hiding this comment.
Use referential equality to validate identity.
toStrictEqual will pass even if queryOptions returns a cloned object. For “returns the same object” semantics, assert reference equality with toBe.
✅ Proposed change
- expect(queryOptions(object)).toStrictEqual(object)
+ expect(queryOptions(object)).toBe(object)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('should return the object received as a parameter without any modification.', () => { | |
| const object: SolidQueryOptions = { | |
| queryKey: ['key'], | |
| queryFn: () => Promise.resolve(5), | |
| } as const | |
| expect(queryOptions(object)).toStrictEqual(object) | |
| it('should return the object received as a parameter without any modification.', () => { | |
| const object: SolidQueryOptions = { | |
| queryKey: ['key'], | |
| queryFn: () => Promise.resolve(5), | |
| } as const | |
| expect(queryOptions(object)).toBe(object) | |
| }) |
🤖 Prompt for AI Agents
In `@packages/solid-query/src/__tests__/queryOptions.test.tsx` around lines 6 -
12, The test currently uses toStrictEqual which allows clones to pass; change
the assertion to use reference equality so it verifies the same object instance
is returned—update the test in queryOptions.test.tsx to replace
expect(queryOptions(object)).toStrictEqual(object) with
expect(queryOptions(object)).toBe(object) so the queryOptions function's
identity contract (returning the same object) is correctly asserted.
db6568b to
29a4226
Compare
🎯 Changes
Add a runtime test for
queryOptionsto verify it returns the received object without any modification, consistent with the existing test inreact-query.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit