Add tests for modules/ui/layout/tab (#3535)
Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: FellipeMTX <fellipefacdir@gmail.com>
This commit is contained in:
@ -0,0 +1,35 @@
|
|||||||
|
import { act } from 'react-dom/test-utils';
|
||||||
|
import { renderHook } from '@testing-library/react';
|
||||||
|
import { RecoilRoot, useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
|
import { useTabList } from '../useTabList';
|
||||||
|
|
||||||
|
describe('useTabList', () => {
|
||||||
|
it('Should update the activeTabId state', async () => {
|
||||||
|
const { result } = renderHook(
|
||||||
|
() => {
|
||||||
|
const { getActiveTabIdState, setActiveTabId } =
|
||||||
|
useTabList('TEST_TAB_LIST_ID');
|
||||||
|
const activeTabId = useRecoilValue(getActiveTabIdState());
|
||||||
|
|
||||||
|
return {
|
||||||
|
getActiveTabIdState: getActiveTabIdState,
|
||||||
|
activeTabId,
|
||||||
|
setActiveTabId: setActiveTabId,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
{
|
||||||
|
wrapper: RecoilRoot,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
expect(result.current.getActiveTabIdState).toBeInstanceOf(Function);
|
||||||
|
expect(result.current.setActiveTabId).toBeInstanceOf(Function);
|
||||||
|
expect(result.current.activeTabId).toBeNull();
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
result.current.setActiveTabId('test-value');
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.current.activeTabId).toBe('test-value');
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user