Skip to content

Commit c4d67cd

Browse files
author
devgioele
committed
add number example to next router tests
1 parent 9d7478c commit c4d67cd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/routers/__test__/nextRouter.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,19 @@ describe('NextRouter', () => {
180180
test('setting a query key should not overwrite other query keys', () => {
181181
const search = 'Max'
182182
const department = 'IT'
183+
const defaultAge = 42
183184

184185
const schema = z.object({
185186
search: z.string().optional().catch(undefined),
186187
department: z.string().optional().catch(undefined),
188+
age: z.string().pipe(z.coerce.number().optional()).catch(undefined),
187189
})
188190

189191
const { result } = renderHook(() =>
190-
useNextRouterQuery({ search: '', department: '' }, schema)
192+
useNextRouterQuery(
193+
{ search: '', department: '', age: defaultAge },
194+
schema
195+
)
191196
)
192197

193198
act(() => {
@@ -200,6 +205,7 @@ describe('NextRouter', () => {
200205

201206
expect(result.current.query.search).toBe(search)
202207
expect(result.current.query.department).toBe(department)
208+
expect(result.current.query.age).toBe(defaultAge)
203209
})
204210

205211
test('unspecified query keys should be left untouched', () => {

0 commit comments

Comments
 (0)