Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/solid-query/src/__tests__/queryOptions.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, expect, it } from 'vitest'
import { queryOptions } from '../queryOptions'

describe('queryOptions', () => {
it('should return the object received as a parameter without any modification.', () => {
const object = {
queryKey: ['key'],
queryFn: () => Promise.resolve(5),
} as const

expect(queryOptions(object)).toStrictEqual(object)
Comment on lines 5 to 11
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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.

})
})
Loading