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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, expect, it } from 'vitest'
import { queryOptions } from '../../src/index.js'

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)
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 toBe instead of toStrictEqual to assert reference identity.

The PR explicitly targets testing the identity function contract β€” that queryOptions returns the exact same object reference passed in. queryOptions "just returns whatever you pass into it" at runtime, so the test should verify reference equality (===), not structural equality.

toStrictEqual performs a deep value comparison. It would pass even if queryOptions returned a new object with the same shape (same queryFn reference and equal queryKey elements), silently allowing a regression if the implementation ever copies the input instead of returning it directly.

πŸ› Proposed fix
-    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
expect(queryOptions(object)).toStrictEqual(object)
expect(queryOptions(object)).toBe(object)
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/svelte-query/tests/queryOptions/queryOptions.svelte.test.ts` at line
11, The test currently asserts structural equality but should assert reference
identity; update the assertion in the test for queryOptions to use toBe instead
of toStrictEqual so it verifies that queryOptions(object) returns the exact same
object reference (i.e., expect(queryOptions(object)).toBe(object)); locate the
assertion referencing queryOptions in the queryOptions.svelte.test.ts and
replace the matcher accordingly.

})
})
Loading