Skip to content

Commit 5e7d224

Browse files
test(useIsActive): Add test that was ensures isActive updates when states change
1 parent ec4ce5d commit 5e7d224

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/hooks/__tests__/useIsActive.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,18 @@ describe('useIsActive', () => {
8888
wrapper.setProps({ params: { param: 'bar' } }).update();
8989
expect(wrapper.find('div').props().className).toBe('yesactive');
9090
});
91+
92+
it('updates when the active state changes', async () => {
93+
await routerGo('state2');
94+
const wrapper = mountInRouter(<TestComponent state="state1" params={null} exact={false} />);
95+
expect(wrapper.find('div').props().className).toBe('notactive');
96+
97+
await routerGo('state1');
98+
wrapper.update();
99+
expect(wrapper.find('div').props().className).toBe('yesactive');
100+
101+
await routerGo('state2');
102+
wrapper.update();
103+
expect(wrapper.find('div').props().className).toBe('notactive');
104+
});
91105
});

0 commit comments

Comments
 (0)