How to use react-hooks-testing-library - 7 common examples

To help you get started, we’ve selected a few react-hooks-testing-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mlaursen / react-md / packages / wia-aria / src / __tests__ / useFocusableElementsCache.tsx View on Github external
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();
  });
github roginfarrer / react-collapsed / src / __tests__ / collapse.jest.js View on Github external
test('toggleOpen toggles isOpen', () => {
  const {result} = renderHook(useCollapse);
  const {toggleOpen} = result.current;
  act(toggleOpen);
  const {isOpen} = result.current;
  expect(isOpen).toBe(true);
});
github roginfarrer / react-collapsed / src / __tests__ / collapse.hook.jest.js View on Github external
test('toggleOpen toggles isOpen', () => {
  const {result} = renderHook(useCollapse);
  const {toggleOpen} = result.current;
  act(toggleOpen);
  const {isOpen} = result.current;
  expect(isOpen).toBe(true);
});
github mlaursen / react-md / packages / utils / src / hooks / __tests__ / useVisibility.ts View on Github external
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);
  });
github roginfarrer / react-collapsed / src / __tests__ / collapse.jest.js View on Github external
test('toggleOpen toggles isOpen', () => {
  const {result} = renderHook(useCollapse);
  const {toggleOpen} = result.current;
  act(toggleOpen);
  const {isOpen} = result.current;
  expect(isOpen).toBe(true);
});
github roginfarrer / react-collapsed / src / __tests__ / collapse.hook.jest.js View on Github external
test('toggleOpen toggles isOpen', () => {
  const {result} = renderHook(useCollapse);
  const {toggleOpen} = result.current;
  act(toggleOpen);
  const {isOpen} = result.current;
  expect(isOpen).toBe(true);
});
github ibitcy / react-stores / tests / testspec.tsx View on Github external
function renderCustomHook(
		initialProps: IUseStoreProps = {
			store,
		},
	) {
		return renderHook, StoreState | Partial>(useStore, {
			initialProps,
		});
	}
});

react-hooks-testing-library

Simple component wrapper for testing React hooks

MIT
Latest version published 6 years ago

Package Health Score

61 / 100
Full package analysis

Popular react-hooks-testing-library functions

Similar packages