-
Notifications
You must be signed in to change notification settings - Fork 98
Closed
Description
This is the same problem that was raised in #54, but the fix in #61 only seems to work if the history object provided in context has a location
property. However, some of the functions which create a history object from React and Reach router, like adaptWindowHistory
and adaptReachHistory
, explicitly don't put that location object on it. This is awkward because now we can write code that works in the browser but fails in tests.
Here's an example of a test that I can add to src/__tests__/useQueryParam-test.tsx
that fails, but should be passing if the bug in #61 was fixed:
it('sets distinct params in the same render', () => {
const { wrapper } = setupWrapper({
foo: '1',
bar: '1',
});
const { result, rerender } = renderHook(
() => [
useQueryParam('foo', NumberParam),
useQueryParam('bar', NumberParam),
],
{ wrapper }
);
const [[foo1, setFoo], [bar1, setBar]] = result.current;
expect([foo1, bar1]).toEqual([1, 1]);
setFoo(2, 'replaceIn');
setBar(2, 'replaceIn');
rerender();
const [[foo2], [bar2]] = result.current;
expect([foo2, bar2]).toEqual([2, 2]); // Fails, instead receiving [1, 2]
});
I'm not sure yet if this can be reproduced in a browser.
Metadata
Metadata
Assignees
Labels
No labels