MCPcopy Create free account
hub / github.com/streamich/react-use / checkOnMountAndUnmount

Function checkOnMountAndUnmount

tests/useEvent.test.ts:65–86  ·  view source on GitHub ↗
(
  props: Props,
  addEventListenerName: string,
  removeEventListenerName: string
)

Source from the content-addressed store, hash-verified

63});
64
65const checkOnMountAndUnmount = (
66 props: Props,
67 addEventListenerName: string,
68 removeEventListenerName: string
69) => {
70 const { unmount } = renderHook((p: Props) => useEvent(p.name, p.handler, p.target, p.options), {
71 initialProps: props,
72 });
73 expect(props.target[addEventListenerName]).toHaveBeenCalledTimes(1);
74 expect(props.target[addEventListenerName]).toHaveBeenLastCalledWith(
75 props.name,
76 props.handler,
77 props.options
78 );
79 unmount();
80 expect(props.target[removeEventListenerName]).toHaveBeenCalledTimes(1);
81 expect(props.target[removeEventListenerName]).toHaveBeenLastCalledWith(
82 props.name,
83 props.handler,
84 props.options
85 );
86};
87
88const checkOnDepsChanges = (
89 props1: Props,

Callers 1

useEvent.test.tsFile · 0.85

Calls 1

useEventFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…