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,15 @@
import { describe, expect, it } from 'vitest'
import { infiniteQueryOptions } from '../../src/index.js'

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

expect(infiniteQueryOptions(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

Assert reference identity, not just deep equality.

toStrictEqual will still pass if infiniteQueryOptions returns a new object with the same shape. If the goal is identity/no mutation, use toBe (optionally keep toStrictEqual too).

βœ… Proposed test tweak
-    expect(infiniteQueryOptions(object)).toStrictEqual(object)
+    expect(infiniteQueryOptions(object)).toBe(object)
+    expect(infiniteQueryOptions(object)).toStrictEqual(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(infiniteQueryOptions(object)).toStrictEqual(object)
expect(infiniteQueryOptions(object)).toBe(object)
expect(infiniteQueryOptions(object)).toStrictEqual(object)
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/svelte-query/tests/infiniteQueryOptions/infiniteQueryOptions.svelte.test.ts`
at line 14, The test currently asserts deep equality but intends to verify no
mutation/identity preservation: change the assertion in the test that calls
infiniteQueryOptions(object) so it asserts reference identity using toBe (you
can optionally keep toStrictEqual as an additional check), i.e., replace or
augment the existing expect(infiniteQueryOptions(object)).toStrictEqual(object)
with expect(...).toBe(object) while keeping the call to infiniteQueryOptions for
locating the check.

})
})
Loading