1- import { renderHook , act } from '@testing-library/react' ;
2- import { MemoryRouter , useLocation } from 'react-router' ;
3- import { describe , it , expect } from 'vitest' ;
1+ import { act , renderHook } from '@testing-library/react' ;
2+ import type React from 'react' ;
3+ import { type Location , MemoryRouter , useLocation } from 'react-router' ;
4+ import { describe , expect , it } from 'vitest' ;
45import { useDataTableUrlState } from './use-data-table-url-state' ;
5- import React from 'react' ;
66
77describe ( 'useDataTableUrlState' , ( ) => {
88 it ( 'should parse initial state from URL' , ( ) => {
99 const wrapper = ( { children } : { children : React . ReactNode } ) => (
10- < MemoryRouter initialEntries = { [ '/?search=initial&page=2&pageSize=20' ] } >
11- { children }
12- </ MemoryRouter >
10+ < MemoryRouter initialEntries = { [ '/?search=initial&page=2&pageSize=20' ] } > { children } </ MemoryRouter >
1311 ) ;
1412
1513 const { result } = renderHook ( ( ) => useDataTableUrlState ( ) , { wrapper } ) ;
@@ -20,7 +18,7 @@ describe('useDataTableUrlState', () => {
2018 } ) ;
2119
2220 it ( 'should update URL state' , ( ) => {
23- let testLocation : any ;
21+ let testLocation : Location | undefined ;
2422
2523 const LocationSpy = ( ) => {
2624 testLocation = useLocation ( ) ;
@@ -41,6 +39,6 @@ describe('useDataTableUrlState', () => {
4139 } ) ;
4240
4341 expect ( result . current . urlState . search ) . toBe ( 'updated' ) ;
44- expect ( testLocation . search ) . toContain ( 'search=updated' ) ;
42+ expect ( testLocation ? .search ) . toContain ( 'search=updated' ) ;
4543 } ) ;
4644} ) ;
0 commit comments