Skip to content

Commit df4afd6

Browse files
author
Vincent Comby
committed
Add test to make sure we keep the hash fragment in URL
1 parent bccbca4 commit df4afd6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/useQueryParamsState.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,4 +805,25 @@ describe('With other query params outside of the schema', () => {
805805
'?utm_source=Google&stringParam=hello'
806806
);
807807
});
808+
809+
test("It doesn't remove the hash fragment during an update", () => {
810+
const url = '/test?booleanParam=true&stringParam=test#myId';
811+
history.push(url);
812+
813+
const { result } = renderHook(
814+
() => useQueryParamsState(queryParamsStateSchema),
815+
{ wrapper }
816+
);
817+
818+
act(() => {
819+
const setParams = result.current[1];
820+
setParams({
821+
stringParam: 'hello',
822+
});
823+
});
824+
825+
expect(history.createHref(history.location)).toEqual(
826+
'/test?booleanParam=true&stringParam=hello#myId'
827+
);
828+
});
808829
});

0 commit comments

Comments
 (0)