-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added jest test case for the same
- Loading branch information
1 parent
d8eb44a
commit d66cc34
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
frontend/src/hooks/useResourceAttribute/__tests__/useResourceAttribute.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { act, renderHook, waitFor } from '@testing-library/react'; | ||
import { createMemoryHistory } from 'history'; | ||
import { Router } from 'react-router-dom'; | ||
|
||
import ResourceProvider from '../ResourceProvider'; | ||
import useResourceAttribute from '../useResourceAttribute'; | ||
|
||
describe('useResourceAttribute component hook', () => { | ||
it('should not change other query params except for resourceAttribute', async () => { | ||
const history = createMemoryHistory({ | ||
initialEntries: ['/inital-url?tab=overview'], | ||
}); | ||
const wrapper = ({ children }: { children: any }): JSX.Element => ( | ||
<Router history={history}> | ||
<ResourceProvider>{children}</ResourceProvider> | ||
</Router> | ||
); | ||
const { result } = renderHook(() => useResourceAttribute(), { wrapper }); | ||
|
||
act(() => { | ||
result.current.handleEnvironmentChange(['production']); | ||
}); | ||
|
||
await waitFor(() => | ||
expect(history.location.search).toContain('tab=overview'), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters