Skip to content

Commit f8f87a3

Browse files
committed
refactor: reorder test cases for clarity
1 parent 8057397 commit f8f87a3

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

site/src/hooks/useSearchParamsKey.test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ describe(useSearchParamsKey.name, () => {
7575
expect(search.get(key)).toEqual(null);
7676
});
7777

78+
it("Will dispatch state changes through custom URLSearchParams value if provided", async () => {
79+
const key = "love";
80+
const initialValue = "dogs";
81+
const customParams = new URLSearchParams({ [key]: initialValue });
82+
83+
const { result } = await renderHookWithAuth(
84+
({ key }) => useSearchParamsKey({ key, searchParams: customParams }),
85+
{
86+
routingOptions: { route: `/?=${key}=${initialValue}` },
87+
renderOptions: { initialProps: { key } },
88+
},
89+
);
90+
91+
const newValue = "all animals";
92+
void act(() => result.current.setValue(newValue));
93+
await waitFor(() => expect(customParams.get(key)).toEqual(newValue));
94+
});
95+
7896
it("Does not have methods change previous values if 'key' argument changes during re-renders", async () => {
7997
const readonlyKey = "readonlyKey";
8098
const mutableKey = "mutableKey";
@@ -100,22 +118,4 @@ describe(useSearchParamsKey.name, () => {
100118
expect(search.get(readonlyKey)).toEqual(initialReadonlyValue);
101119
expect(search.get(mutableKey)).toEqual(swapValue);
102120
});
103-
104-
it("Will dispatch state changes through custom URLSearchParams value if provided", async () => {
105-
const key = "love";
106-
const initialValue = "dogs";
107-
const customParams = new URLSearchParams({ [key]: initialValue });
108-
109-
const { result } = await renderHookWithAuth(
110-
({ key }) => useSearchParamsKey({ key, searchParams: customParams }),
111-
{
112-
routingOptions: { route: `/?=${key}=${initialValue}` },
113-
renderOptions: { initialProps: { key } },
114-
},
115-
);
116-
117-
const newValue = "all animals";
118-
void act(() => result.current.setValue(newValue));
119-
await waitFor(() => expect(customParams.get(key)).toEqual(newValue));
120-
});
121121
});

0 commit comments

Comments
 (0)