@@ -6,7 +6,7 @@ import { useUrlState } from "./useUrlState";
66describe ( "useUrlState" , ( ) => {
77 const emptyUrlStateDecoded = { } ;
88 const emptyUrlStateEncoded = "e30%3D" ;
9- const setLocationHash = jest . fn ( ) ;
9+ const onEncodedState = jest . fn ( ) ;
1010 const fallbackEmptyUrlState = jest . fn ( ( ) => emptyUrlStateDecoded ) ;
1111 const urlStateEncodedInvalid = "#!!invalid@!" ;
1212
@@ -27,9 +27,9 @@ describe("useUrlState", () => {
2727
2828 const { result } = renderHook ( ( ) =>
2929 useUrlState ( {
30- getLocationHash : ( ) => encodedState ,
30+ getEncodedState : ( ) => encodedState ,
3131 handleDecodeError,
32- setLocationHash ,
32+ onEncodedState : onEncodedState ,
3333 } ) ,
3434 ) ;
3535
@@ -48,17 +48,20 @@ describe("useUrlState", () => {
4848 ${ "next state is function" } | ${ jest . fn ( ( ) => emptyUrlStateDecoded ) }
4949 ` ( "sets location hash to encoded state value" , ( { nextStateAction } ) => {
5050 const { result } = renderHook ( ( ) =>
51- useUrlState ( { getLocationHash : ( ) => urlStateEncoded , setLocationHash } ) ,
51+ useUrlState ( {
52+ getEncodedState : ( ) => urlStateEncoded ,
53+ onEncodedState : onEncodedState ,
54+ } ) ,
5255 ) ;
5356 const [ , setState ] = result . current ;
5457
55- expect ( setLocationHash ) . not . toHaveBeenCalled ( ) ;
58+ expect ( onEncodedState ) . not . toHaveBeenCalled ( ) ;
5659 setState ( nextStateAction ) ;
5760 if ( typeof nextStateAction === "function" ) {
5861 expect ( nextStateAction ) . toHaveBeenCalledTimes ( 1 ) ;
5962 expect ( nextStateAction ) . toHaveBeenLastCalledWith ( urlStateDecoded ) ;
6063 }
61- expect ( setLocationHash ) . toHaveBeenCalledTimes ( 1 ) ;
62- expect ( setLocationHash ) . toHaveBeenLastCalledWith ( emptyUrlStateEncoded ) ;
64+ expect ( onEncodedState ) . toHaveBeenCalledTimes ( 1 ) ;
65+ expect ( onEncodedState ) . toHaveBeenLastCalledWith ( emptyUrlStateEncoded ) ;
6366 } ) ;
6467} ) ;
0 commit comments