Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should not do anything if there is no ref or instance", () => {
let { result } = renderHook(() => useFocusableElementsCache(null));
expect(result.current).toEqual({ current: [] });
expect(getFocusableElements).not.toBeCalled();
({ result } = renderHook(() =>
useFocusableElementsCache({ current: null })
));
expect(result.current).toEqual({ current: [] });
expect(getFocusableElements).not.toBeCalled();
});
test('toggleOpen toggles isOpen', () => {
const {result} = renderHook(useCollapse);
const {toggleOpen} = result.current;
act(toggleOpen);
const {isOpen} = result.current;
expect(isOpen).toBe(true);
});
test('toggleOpen toggles isOpen', () => {
const {result} = renderHook(useCollapse);
const {toggleOpen} = result.current;
act(toggleOpen);
const {isOpen} = result.current;
expect(isOpen).toBe(true);
});
it("should default the visibility to the provided defaultVisible value", () => {
let { result } = renderHook(() => useVisibility(false));
expect(result.current.visible).toBe(false);
({ result } = renderHook(() => useVisibility(true)));
expect(result.current.visible).toBe(true);
});
function renderCustomHook(
initialProps: IUseStoreProps = {
store,
},
) {
return renderHook, StoreState | Partial>(useStore, {
initialProps,
});
}
});