repo
stringlengths
7
64
file_url
stringlengths
81
338
file_path
stringlengths
5
257
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:25:31
2026-01-05 01:50:38
truncated
bool
2 classes
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/misc/hookState.ts
src/misc/hookState.ts
export type IHookStateInitialSetter<S> = () => S; export type IHookStateInitAction<S> = S | IHookStateInitialSetter<S>; export type IHookStateSetter<S> = ((prevState: S) => S) | (() => S); export type IHookStateSetAction<S> = S | IHookStateSetter<S>; export type IHookStateResolvable<S> = S | IHookStateInitialSetter<S...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/misc/parseTimeRanges.ts
src/misc/parseTimeRanges.ts
export default function parseTimeRanges(ranges) { const result: { start: number; end: number }[] = []; for (let i = 0; i < ranges.length; i++) { result.push({ start: ranges.start(i), end: ranges.end(i), }); } return result; }
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/component/UseKey.tsx
src/component/UseKey.tsx
import useKey from '../useKey'; import createRenderProp from '../factory/createRenderProp'; const UseKey = createRenderProp(useKey, ({ filter, fn, deps, ...rest }) => [ filter, fn, rest, deps, ]); export default UseKey;
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createReducer.ts
src/factory/createReducer.ts
import { MutableRefObject, useCallback, useRef, useState } from 'react'; import useUpdateEffect from '../useUpdateEffect'; type Dispatch<Action> = (action: Action) => void; interface Store<Action, State> { getState: () => State; dispatch: Dispatch<Action>; } type Middleware<Action, State> = ( store: Store<Acti...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createBreakpoint.ts
src/factory/createBreakpoint.ts
import { useEffect, useMemo, useState } from 'react'; import { isBrowser, off, on } from '../misc/util'; const createBreakpoint = (breakpoints: { [name: string]: number } = { laptopL: 1440, laptop: 1024, tablet: 768 }) => () => { const [screen, setScreen] = useState(isBrowser ? window.innerWidth : 0); use...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createMemo.ts
src/factory/createMemo.ts
import { useMemo } from 'react'; const createMemo = <T extends (...args: any) => any>(fn: T) => (...args: Parameters<T>) => useMemo<ReturnType<T>>(() => fn(...args), args); export default createMemo;
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createRenderProp.ts
src/factory/createRenderProp.ts
const defaultMapPropsToArgs = (props) => [props]; export default function createRenderProp(hook, mapPropsToArgs = defaultMapPropsToArgs) { return function RenderProp(props) { const state = hook(...mapPropsToArgs(props)); const { children, render = children } = props; return render ? render(state) || null...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createGlobalState.ts
src/factory/createGlobalState.ts
import { useState } from 'react'; import { IHookStateInitAction, IHookStateSetAction, resolveHookState } from '../misc/hookState'; import useEffectOnce from '../useEffectOnce'; import useIsomorphicLayoutEffect from '../useIsomorphicLayoutEffect'; export function createGlobalState<S = any>( initialState: IHookStateIn...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createReducerContext.ts
src/factory/createReducerContext.ts
import { createContext, createElement, useContext, useReducer } from 'react'; const createReducerContext = <R extends React.Reducer<any, any>>( reducer: R, defaultInitialState: React.ReducerState<R> ) => { const context = createContext<[React.ReducerState<R>, React.Dispatch<React.ReducerAction<R>>] | undefin...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createRouter.ts
src/factory/createRouter.ts
import React from 'react'; export interface RouterProviderProps { route: string; fullRoute?: string; parent?: any; } const createRouter = () => { const context = React.createContext<RouterProviderProps>({ route: '', }); // not sure if this supposed to be unused, ignoring ts error for now // @ts-ign...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createHTMLMediaHook.ts
src/factory/createHTMLMediaHook.ts
import * as React from 'react'; import { useEffect, useRef } from 'react'; import useSetState from '../useSetState'; import parseTimeRanges from '../misc/parseTimeRanges'; export interface HTMLMediaProps extends React.AudioHTMLAttributes<any>, React.VideoHTMLAttributes<any> { src: string; } export interface H...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/src/factory/createStateContext.ts
src/factory/createStateContext.ts
import { createContext, createElement, useContext, useState } from 'react'; const createStateContext = <T>(defaultInitialValue: T) => { const context = createContext<[T, React.Dispatch<React.SetStateAction<T>>] | undefined>(undefined); const providerFactory = (props, children) => createElement(context.Provider...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useStateWithHistory.test.ts
tests/useStateWithHistory.test.ts
import { act, renderHook, RenderHookResult } from '@testing-library/react-hooks'; import { useRef } from 'react'; import { UseStateHistoryReturn, useStateWithHistory } from '../src/useStateWithHistory'; import { IHookStateSetAction } from '../src/misc/hookState'; describe('useStateWithHistory', () => { it('should be...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useRaf.test.ts
tests/useRaf.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import { replaceRaf } from 'raf-stub'; import useRaf from '../src/useRaf'; /** * New requestAnimationFrame after being replaced with raf-stub for testing purposes. */ interface RequestAnimationFrame { reset(): void; step(): void; } declare var req...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useMultiStateValidator.test.ts
tests/useMultiStateValidator.test.ts
import { act, renderHook, RenderHookResult } from '@testing-library/react-hooks'; import { useState } from 'react'; import { MultiStateValidator, useMultiStateValidator } from '../src/useMultiStateValidator'; import { UseStateValidatorReturn, ValidityState } from '../src/useStateValidator'; interface Mock extends jest...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useMountedState.test.tsx
tests/useMountedState.test.tsx
import { renderHook } from '@testing-library/react-hooks'; import useMountedState from '../src/useMountedState'; describe('useMountedState', () => { it('should be defined', () => { expect(useMountedState).toBeDefined(); }); it('should return a function', () => { const hook = renderHook(() => useMountedS...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useDefault.test.ts
tests/useDefault.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useDefault from '../src/useDefault'; const setUp = (defaultValue: any, initialValue: any) => renderHook(() => useDefault(defaultValue, initialValue)); describe.each` valueType | defaultValue | initialValue | anotherValue ${'num...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useRendersCount.test.ts
tests/useRendersCount.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useRendersCount } from '../src'; describe('useRendersCount', () => { it('should be defined', () => { expect(useRendersCount).toBeDefined(); }); it('should return number', () => { expect(renderHook(() => useRendersCount()).result.current...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useThrottleFn.test.ts
tests/useThrottleFn.test.ts
import { renderHook, RenderHookResult } from '@testing-library/react-hooks'; import { useThrottleFn } from '../src'; describe('useThrottleFn', () => { beforeAll(() => { jest.useFakeTimers(); }); afterAll(() => { jest.useRealTimers(); }); afterEach(() => { jest.clearAllTimers(); }); it('shoul...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useStateList.test.ts
tests/useStateList.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useStateList from '../src/useStateList'; describe('useStateList', () => { it('should be defined', () => { expect(useStateList).toBeDefined(); }); function getHook(list: any[] = ['a', 'b', 'c']) { return renderHook(({ states }) => use...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useScrollbarWidth.test.ts
tests/useScrollbarWidth.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import { scrollbarWidth } from '@xobotyi/scrollbar-width'; import { useScrollbarWidth } from '../src'; import { replaceRaf } from 'raf-stub'; declare var requestAnimationFrame: { add: (cb: Function) => number; remove: (id: number) => void; flush: (d...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useUpdate.test.ts
tests/useUpdate.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useUpdate from '../src/useUpdate'; describe('useUpdate', () => { it('should be defined', () => { expect(useUpdate).toBeDefined(); }); it('should return a function', () => { const { result } = renderHook(() => useUpdate()); expec...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useList.test.ts
tests/useList.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import { useRef } from 'react'; import useList, { ListActions } from '../src/useList'; describe('useList', () => { it('should be defined', () => { expect(useList).toBeDefined(); }); function getHook<T>(initialArray?: T[]) { return renderHoo...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useMeasure.test.ts
tests/useMeasure.test.ts
import { renderHook, act } from '@testing-library/react-hooks'; import useMeasure, { UseMeasureRef } from '../src/useMeasure'; it('by default, state defaults every value to -1', () => { const { result } = renderHook(() => useMeasure()); act(() => { const div = document.createElement('div'); (result.curren...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useLocalStorage.test.ts
tests/useLocalStorage.test.ts
import useLocalStorage from '../src/useLocalStorage'; import 'jest-localstorage-mock'; import { renderHook, act } from '@testing-library/react-hooks'; describe(useLocalStorage, () => { afterEach(() => { localStorage.clear(); jest.clearAllMocks(); }); it('retrieves an existing value from localStorage', (...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useError.test.ts
tests/useError.test.ts
import { renderHook, act } from '@testing-library/react-hooks'; import { useError } from '../src'; const setup = () => renderHook(() => useError()); beforeEach(() => { jest.spyOn(console, 'error').mockImplementation(() => {}); }); afterEach(() => { jest.clearAllMocks(); }); it('should throw an error on error di...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useGetSet.test.ts
tests/useGetSet.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useGetSet from '../src/useGetSet'; const setUp = (initialValue: any) => renderHook(() => useGetSet(initialValue)); beforeEach(() => { jest.useFakeTimers(); }); it('should init getter and setter', () => { const { result } = setUp('foo'); con...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useLatest.test.ts
tests/useLatest.test.ts
import { renderHook } from '@testing-library/react-hooks'; import useLatest from '../src/useLatest'; const setUp = () => renderHook(({ state }) => useLatest(state), { initialProps: { state: 0 } }); it('should return a ref with the latest value on initial render', () => { const { result } = setUp(); expect(result...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useMethods.test.ts
tests/useMethods.test.ts
import { renderHook, act } from '@testing-library/react-hooks'; import { useMethods } from '../src'; it('should have initialState value as the returned state value', () => { const initialState = { count: 10, }; const createMethods = (state) => ({ doStuff: () => state, }); const { result } = renderH...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useTween.test.ts
tests/useTween.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { easing } from 'ts-easing'; import * as useRaf from '../src/useRaf'; import useTween from '../src/useTween'; let spyUseRaf; let spyEasingInCirc; let spyEasingOutCirc; beforeEach(() => { spyUseRaf = jest.spyOn(useRaf, 'default').mockReturnValue(17); ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useEvent.test.ts
tests/useEvent.test.ts
import { renderHook } from '@testing-library/react-hooks'; import useEvent, { ListenerType1, ListenerType2 } from '../src/useEvent'; interface Props { name: string; handler: (...args: any[]) => void; target: ListenerType1 | ListenerType2; options: any; } const propsList1 = [ { name: 'name1', handler...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useDebounce.test.ts
tests/useDebounce.test.ts
import { act, renderHook, RenderHookResult } from '@testing-library/react-hooks'; import { DependencyList } from 'react'; import { UseDebounceReturn } from '../src/useDebounce'; import { useDebounce } from '../src'; describe('useDebounce', () => { beforeAll(() => { jest.useFakeTimers(); }); afterEach(() => ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useUnmount.test.ts
tests/useUnmount.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useUnmount } from '../src'; describe('useUnmount', () => { it('should be defined', () => { expect(useUnmount).toBeDefined(); }); it('should not call provided callback on mount', () => { const spy = jest.fn(); renderHook(() => useUnm...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useIntersection.test.tsx
tests/useIntersection.test.tsx
import React, { createRef } from 'react'; import ReactDOM from 'react-dom'; import TestUtils from 'react-dom/test-utils'; import TestRenderer from 'react-test-renderer'; import { intersectionObserver } from '@shopify/jest-dom-mocks'; import { renderHook } from '@testing-library/react-hooks'; import { useIntersection } ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useShallowCompareEffect.test.ts
tests/useShallowCompareEffect.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useShallowCompareEffect } from '../src'; import { useEffect } from 'react'; let options1 = { max: 10, range: { from: 0, to: 10 } }; const options2 = { max: 10, range: { from: 0, to: 10 } }; const mockEffectNormal = jest.fn(); const mockEffectShallow =...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/setupTests.ts
tests/setupTests.ts
import 'jest-localstorage-mock'; import { isBrowser } from '../src/misc/util'; if (isBrowser) { (window as any).ResizeObserver = class ResizeObserver { observe() {} disconnect() {} }; }
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useEffectOnce.test.ts
tests/useEffectOnce.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useEffectOnce } from '../src'; const mockEffectCleanup = jest.fn(); const mockEffectCallback = jest.fn().mockReturnValue(mockEffectCleanup); it('should run provided effect only once', () => { const { rerender } = renderHook(() => useEffectOnce(mock...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useMedia.test.ts
tests/useMedia.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { renderHook as renderHookSSR } from '@testing-library/react-hooks/server'; import { useMedia } from '../src'; const createMockMediaMatcher = (matches: Record<string, boolean>) => (qs: string) => ({ matches: matches[qs] ?? false, addEventListener: (...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useQueue.test.ts
tests/useQueue.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useQueue from '../src/useQueue'; const setUp = (initialQueue?: any[]) => renderHook(() => useQueue(initialQueue)); it('takes initial state', () => { const { result } = setUp([1, 2, 3]); const { first, last, size } = result.current; expect(fi...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useSearchParam.test.ts
tests/useSearchParam.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useSearchParam from '../src/useSearchParam'; const { location } = window; let mockSearch: string; beforeEach(() => { delete (window as any).location; const { search, ...restLocation } = location; // @ts-ignore window.location = { ...rest...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useAsync.test.tsx
tests/useAsync.test.tsx
import { renderHook } from '@testing-library/react-hooks'; import { useCallback } from 'react'; import useAsync from '../src/useAsync'; describe('useAsync', () => { it('should be defined', () => { expect(useAsync).toBeDefined(); }); describe('a success', () => { let hook; let callCount = 0; con...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useNumber.test.ts
tests/useNumber.test.ts
import useCounter from '../src/useCounter'; import useNumber from '../src/useNumber'; it('should be an alias for useCounter', () => { expect(useNumber).toBe(useCounter); });
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/createStateContext.test.tsx
tests/createStateContext.test.tsx
import React from 'react'; import { render, fireEvent } from '@testing-library/react'; import { act, renderHook } from '@testing-library/react-hooks'; import createStateContext from '../src/factory/createStateContext'; it('should create a hook and a provider', () => { const [useSharedNumber, SharedNumberProvider] = ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useToggle.test.ts
tests/useToggle.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useToggle from '../src/useToggle'; const setUp = (initialValue: boolean) => renderHook(() => useToggle(initialValue)); it('should init state to true', () => { const { result } = setUp(true); expect(result.current[0]).toBe(true); expect(type...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useLongPress.test.tsx
tests/useLongPress.test.tsx
import { renderHook } from '@testing-library/react-hooks'; import useLongPress from '../src/useLongPress'; const callback = jest.fn(); const defaultDelay = 300; const mouseDown = new MouseEvent('mousedown'); const touchStart = new TouchEvent('touchstart'); beforeAll(() => { jest.useFakeTimers(); }); afterEach(() =...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useLogger.test.ts
tests/useLogger.test.ts
import { renderHook } from '@testing-library/react-hooks'; import useLogger from '../src/useLogger'; const logSpy = jest.spyOn(global.console, 'log').mockImplementation(() => {}); describe('useLogger', () => { it('should be defined', () => { expect(useLogger).toBeDefined(); }); it('should log the provided ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/usePreviousDistinct.test.tsx
tests/usePreviousDistinct.test.tsx
import { renderHook } from '@testing-library/react-hooks'; import usePreviousDistinct, { Predicate } from '../src/usePreviousDistinct'; describe('usePreviousDistinct', () => { it('should be defined', () => { expect(usePreviousDistinct).toBeDefined(); }); function getHook<T>(initialValue?: T, predicate?: Pre...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useCookie.test.tsx
tests/useCookie.test.tsx
import { renderHook, act } from '@testing-library/react-hooks'; import Cookies from 'js-cookie'; import { useCookie } from '../src'; const setup = (cookieName: string) => renderHook(() => useCookie(cookieName)); it('should have initial value of null if no cookie exists', () => { const { result } = setup('some-cooki...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useCopyToClipboard.test.ts
tests/useCopyToClipboard.test.ts
import writeText from 'copy-to-clipboard'; import { act, renderHook } from '@testing-library/react-hooks'; import { useCopyToClipboard } from '../src'; const valueToRaiseMockException = 'fake input causing exception in copy to clipboard'; jest.mock('copy-to-clipboard', () => jest.fn().mockImplementation((input) => {...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useRafState.test.ts
tests/useRafState.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import { replaceRaf } from 'raf-stub'; import useRafState from '../src/useRafState'; interface RequestAnimationFrame { reset(): void; step(): void; } declare var requestAnimationFrame: RequestAnimationFrame; replaceRaf(); beforeEach(() => { reque...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useThrottle.test.ts
tests/useThrottle.test.ts
import { renderHook } from '@testing-library/react-hooks'; import useThrottle from '../src/useThrottle'; describe('useThrottle', () => { beforeAll(() => { jest.useFakeTimers(); }); afterEach(() => { jest.clearAllTimers(); }); afterAll(() => { jest.useRealTimers(); }); it('should be defined...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useFirstMountState.test.ts
tests/useFirstMountState.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useFirstMountState } from '../src'; describe('useFirstMountState', () => { it('should be defined', () => { expect(useFirstMountState).toBeDefined(); }); it('should return boolean', () => { expect(renderHook(() => useFirstMountState()).r...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useMap.test.ts
tests/useMap.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useMap from '../src/useMap'; const setUp = <T extends object>(initialMap?: T) => renderHook(() => useMap(initialMap)); it('should init map and utils', () => { const { result } = setUp({ foo: 'bar', a: 1 }); const [map, utils] = result.current;...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useBoolean.test.ts
tests/useBoolean.test.ts
import useBoolean from '../src/useBoolean'; import useToggle from '../src/useToggle'; it('should be an alias for useToggle ', () => { expect(useBoolean).toBe(useToggle); });
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useObservable.test.ts
tests/useObservable.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import { Subject } from 'rxjs'; import * as useIsomorphicLayoutEffect from '../src/useIsomorphicLayoutEffect'; import useObservable, { Observable } from '../src/useObservable'; const setUp = (observable: Observable<any>, initialValue?: any) => renderHoo...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useMount.test.ts
tests/useMount.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useMount } from '../src'; const mockCallback = jest.fn(); afterEach(() => { jest.resetAllMocks(); }); it('should call provided callback on mount', () => { renderHook(() => useMount(mockCallback)); expect(mockCallback).toHaveBeenCalledTimes(1)...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useCustomCompareEffect.test.ts
tests/useCustomCompareEffect.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useCustomCompareEffect } from '../src'; import { useEffect } from 'react'; import isDeepEqual from '../src/misc/isDeepEqual'; let options = { max: 10 }; const mockEffectNormal = jest.fn(); const mockEffectDeep = jest.fn(); const mockEffectCleanup = je...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useDeepCompareEffect.test.ts
tests/useDeepCompareEffect.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useDeepCompareEffect } from '../src'; import { useEffect } from 'react'; let options = { max: 10 }; const mockEffectNormal = jest.fn(); const mockEffectDeep = jest.fn(); const mockEffectCleanup = jest.fn(); const mockEffectCallback = jest.fn().mockRet...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useSet.test.ts
tests/useSet.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useSet from '../src/useSet'; const setUp = <K>(initialSet?: Set<K>) => renderHook(() => useSet(initialSet)); it('should init set and utils', () => { const { result } = setUp(new Set([1, 2])); const [set, utils] = result.current; expect(set)...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useHash.test.ts
tests/useHash.test.ts
import { renderHook, act } from '@testing-library/react-hooks'; import { useHash } from '../src/useHash'; (global as any).window = Object.create(window); let mockHash = '#'; const mockLocation = {}; Object.defineProperty(mockLocation, 'hash', { get() { return mockHash; }, set(newHash) { mockHash = newHas...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useAudio.test.ts
tests/useAudio.test.ts
import { renderHook } from '@testing-library/react-hooks'; import useAudio from '../src/useAudio'; const setUp = ( src: string = 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3', autoPlay: boolean = true ) => renderHook(() => useAudio({ src, autoPlay })); it('should init audio and utils', () => { ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useTitle.test.ts
tests/useTitle.test.ts
import { renderHook } from '@testing-library/react-hooks'; import useTitle from '../src/useTitle'; describe('useTitle', () => { it('should be defined', () => { expect(useTitle).toBeDefined(); }); it('should update document title', () => { const hook = renderHook((props) => useTitle(props), { initialProp...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useTimeoutFn.test.ts
tests/useTimeoutFn.test.ts
import { act, renderHook, RenderHookResult } from '@testing-library/react-hooks'; import { useTimeoutFn } from '../src'; import { UseTimeoutFnReturn } from '../src/useTimeoutFn'; describe('useTimeoutFn', () => { beforeAll(() => { jest.useFakeTimers(); }); afterEach(() => { jest.clearAllTimers(); }); ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useSetState.test.ts
tests/useSetState.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useSetState from '../src/useSetState'; const setUp = (initialState?: object) => renderHook(() => useSetState(initialState)); it('should init state and setter', () => { const { result } = setUp({ foo: 'bar' }); const [state, setState] = result....
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useOrientation.test.ts
tests/useOrientation.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import { replaceRaf } from 'raf-stub'; import useOrientation from '../src/useOrientation'; declare var requestAnimationFrame: { reset: () => void; step: (steps?: number, duration?: number) => void; }; describe('useOrientation', () => { beforeAll(()...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useStateValidator.test.ts
tests/useStateValidator.test.ts
import { act, renderHook, RenderHookResult } from '@testing-library/react-hooks'; import { useState } from 'react'; import useStateValidator, { StateValidator, UseStateValidatorReturn, } from '../src/useStateValidator'; interface Mock extends jest.Mock {} describe('useStateValidator', () => { it('should be defi...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useInterval.test.ts
tests/useInterval.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useInterval } from '../src'; let callback; beforeEach(() => { callback = jest.fn(); }); beforeAll(() => { jest.useFakeTimers(); }); afterEach(() => { callback.mockRestore(); jest.clearAllTimers(); }); afterAll(() => { jest.useRealTimers(...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useUnmountPromise.test.ts
tests/useUnmountPromise.test.ts
import { renderHook } from '@testing-library/react-hooks'; import useUnmountPromise from '../src/useUnmountPromise'; describe('useUnmountPromise', () => { it('should be defined', () => { expect(useUnmountPromise).toBeDefined(); }); it('should return a function', () => { const hook = renderHook(() => use...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/createGlobalState.test.ts
tests/createGlobalState.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import createGlobalState from '../src/factory/createGlobalState'; describe('useGlobalState', () => { it('should be defined', () => { expect(createGlobalState).toBeDefined(); }); it('both components should be updated', () => { const useGloba...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useUpdateEffect.test.ts
tests/useUpdateEffect.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useUpdateEffect } from '../src'; it('should run effect on update', () => { const effect = jest.fn(); const { rerender } = renderHook(() => useUpdateEffect(effect)); expect(effect).not.toHaveBeenCalled(); rerender(); expect(effect).toHaveBe...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useSpring.test.ts
tests/useSpring.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import { Spring } from 'rebound'; import useSpring from '../src/useSpring'; // simulate Spring for testing const mockSetCurrentValue = jest.fn(); const mockAddListener = jest.fn(); const mockSetEndValue = jest.fn(); const mockRemoveListener = jest.fn(); l...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useTimeout.test.ts
tests/useTimeout.test.ts
import { act, renderHook, RenderHookResult } from '@testing-library/react-hooks'; import { useTimeout } from '../src'; import { UseTimeoutReturn } from '../src/useTimeout'; beforeAll(() => { jest.useFakeTimers(); }); afterEach(() => { jest.clearAllTimers(); }); afterAll(() => { jest.useRealTimers(); }); it('s...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useGetSetState.test.ts
tests/useGetSetState.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useGetSetState from '../src/useGetSetState'; const originalConsoleError = console.error; const mockConsoleError = jest.fn(); const setUp = (initialState: any) => renderHook(() => useGetSetState(initialState)); beforeAll(() => { console.error = ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useWindowSize.test.tsx
tests/useWindowSize.test.tsx
import { act, renderHook } from '@testing-library/react-hooks'; import { replaceRaf } from 'raf-stub'; import useWindowSize from '../src/useWindowSize'; import { isBrowser } from '../src/misc/util'; declare var requestAnimationFrame: { reset: () => void; step: (steps?: number, duration?: number) => void; }; descr...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useRafLoop.test.tsx
tests/useRafLoop.test.tsx
import { renderHook } from '@testing-library/react-hooks'; import { replaceRaf } from 'raf-stub'; import useRafLoop from '../src/useRafLoop'; declare var requestAnimationFrame: { add: (cb: Function) => number; remove: (id: number) => void; flush: (duration?: number) => void; reset: () => void; step: (steps?:...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/usePrevious.test.ts
tests/usePrevious.test.ts
import { renderHook } from '@testing-library/react-hooks'; import usePrevious from '../src/usePrevious'; const setUp = () => renderHook(({ state }) => usePrevious(state), { initialProps: { state: 0 } }); it('should return undefined on initial render', () => { const { result } = setUp(); expect(result.current).to...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useEnsuredForwardedRef.test.tsx
tests/useEnsuredForwardedRef.test.tsx
import React, { useRef } from 'react'; import ReactDOM from 'react-dom'; import { renderHook } from '@testing-library/react-hooks'; import TestUtils from 'react-dom/test-utils'; import { ensuredForwardRef, useEnsuredForwardedRef } from '../src'; let container: HTMLDivElement; beforeEach(() => { container = document...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/createBreakpoint.test.ts
tests/createBreakpoint.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import createBreakpoint from '../src/factory/createBreakpoint'; const useBreakpointA = createBreakpoint(); const useBreakpointB = createBreakpoint({ mobileM: 350, laptop: 1024, tablet: 768 }); const originalInnerWidth = window.innerWidth; const changeInn...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useUpsert.test.ts
tests/useUpsert.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useUpsert from '../src/useUpsert'; interface TestItem { id: string; text: string; } const testItems: TestItem[] = [ { id: '1', text: '1' }, { id: '2', text: '2' }, ]; const itemsAreEqual = (a: TestItem, b: TestItem) => { return a.id ===...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useCounter.test.ts
tests/useCounter.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import useCounter from '../src/useCounter'; const setUp = (initialValue?: number, max: number | null = null, min: number | null = null) => renderHook(() => useCounter(initialValue, max, min)); it('should init counter and utils', () => { const { resul...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/createMemo.test.ts
tests/createMemo.test.ts
import { renderHook } from '@testing-library/react-hooks'; import createMemo from '../src/factory/createMemo'; const getDouble = jest.fn((n: number): number => n * 2); it('should init memo hook', () => { const useMemoGetDouble = createMemo(getDouble); expect(useMemoGetDouble).toBeInstanceOf(Function); }); descr...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useWindowScroll.test.tsx
tests/useWindowScroll.test.tsx
import React, { useEffect } from 'react'; import { render, act as reactAct } from '@testing-library/react'; import { act, renderHook } from '@testing-library/react-hooks'; import { replaceRaf } from 'raf-stub'; import useWindowScroll from '../src/useWindowScroll'; declare var requestAnimationFrame: { reset: () => v...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useAsyncFn.test.tsx
tests/useAsyncFn.test.tsx
// NOTE: most behavior that useAsyncFn provides // is covered be the useAsync tests. // // The main difference is that useAsyncFn // does not automatically invoke the function // and it can take arguments. import { act, renderHook } from '@testing-library/react-hooks'; import useAsyncFn, { AsyncState } from '../...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useNetworkState.test.ts
tests/useNetworkState.test.ts
import { renderHook } from '@testing-library/react-hooks'; import { useNetworkState } from '../src'; //ToDo: improve tests describe(`useNetworkState`, () => { it('should be defined', () => { expect(useNetworkState).toBeDefined(); }); it('should return an object of certain structure', () => { const hook ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/createReducer.test.ts
tests/createReducer.test.ts
import { act, renderHook } from '@testing-library/react-hooks'; import logger from 'redux-logger'; import thunk from 'redux-thunk'; import createReducer from '../src/factory/createReducer'; it('should init reducer hook function', () => { const useSomeReducer = createReducer(); expect(useSomeReducer).toBeInstanceOf...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useMediatedState.test.ts
tests/useMediatedState.test.ts
import { act, renderHook, RenderHookResult } from '@testing-library/react-hooks'; import { Dispatch, SetStateAction } from 'react'; import { useMediatedState } from '../src'; import { StateMediator, UseMediatedStateReturn } from '../src/useMediatedState'; describe('useMediatedState', () => { it('should be defined', ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/createReducerContext.test.tsx
tests/createReducerContext.test.tsx
import React from 'react'; import { render, fireEvent } from '@testing-library/react'; import { act, renderHook } from '@testing-library/react-hooks'; import createReducerContext from '../src/factory/createReducerContext'; type Action = 'increment' | 'decrement'; const reducer = (state: number, action: Action) => { ...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/useFavicon.test.tsx
tests/useFavicon.test.tsx
import { renderHook } from '@testing-library/react-hooks'; import useFavicon from '../src/useFavicon'; afterEach(() => { const favicon = document.querySelector("link[rel*='icon']"); if (favicon) { favicon.remove(); } }); describe('useFavicon', () => { it('should be defined', () => { expect(useFavicon)...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
streamich/react-use
https://github.com/streamich/react-use/blob/9ef95352e459dd2920b0492c63c39863024ee852/tests/misc/hookState.test.ts
tests/misc/hookState.test.ts
import { resolveHookState } from '../../src/misc/hookState'; describe('resolveHookState', () => { it('should defined', () => { expect(resolveHookState).toBeDefined(); }); it(`should return value as is if it's not a function`, () => { expect(resolveHookState(1)).toBe(1); expect(resolveHookState('HI!'...
typescript
Unlicense
9ef95352e459dd2920b0492c63c39863024ee852
2026-01-04T15:45:41.983376Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/create-nx-sandbox-projects.ts
scripts/create-nx-sandbox-projects.ts
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import prettier from 'prettier'; import { type Template } from '../code/lib/cli-storybook/src/sandbox-templates'; import * as templates from '../code/lib/cli-storybook/src/sandbox-templates'; // @ts-expect-erro...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/upload-bench.ts
scripts/upload-bench.ts
import { BigQuery } from '@google-cloud/bigquery'; // eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; import { join } from 'path'; import type { BenchResults } from './bench/types'; import { loadBench } from './bench/utils'; import { SANDBOX_DIRECTORY } from './utils/constants'; ...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/vitest.config.ts
scripts/vitest.config.ts
import { defineConfig } from 'vitest/config'; /** * CircleCI reports the wrong number of threads to Node.js, so we need to set it manually. Script * tests are running with the small resource class, which has 1 vCPU. * * @see https://jahed.dev/2022/11/20/fixing-node-js-multi-threading-on-circleci/ * @see https://v...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/task.ts
scripts/task.ts
import { access, mkdir, readFile, writeFile } from 'node:fs/promises'; import type { TestCase } from 'junit-xml'; import { getJunitXml } from 'junit-xml'; import { dirname, join, resolve } from 'path'; import picocolors from 'picocolors'; import { prompt } from 'prompts'; import invariant from 'tiny-invariant'; import...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/run-registry.ts
scripts/run-registry.ts
import { exec } from 'node:child_process'; import { access, mkdir, readFile, rm } from 'node:fs/promises'; import http from 'node:http'; import type { Server } from 'node:http'; import { join, resolve as resolvePath } from 'node:path'; import { program } from 'commander'; import pLimit from 'p-limit'; import picocolor...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/event-log-checker.ts
scripts/event-log-checker.ts
import assert from 'assert'; import picocolors from 'picocolors'; // import versions from '../code/core/src/common/versions'; import { allTemplates } from '../code/lib/cli-storybook/src/sandbox-templates'; import { esMain } from './utils/esmain'; const PORT = process.env.PORT || 6007; type EventType = 'build' | 'tes...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/prepare-sandbox.ts
scripts/prepare-sandbox.ts
import { existsSync } from 'node:fs'; import { cp, rm } from 'node:fs/promises'; import { parseArgs } from 'node:util'; import { join } from 'path'; import waitOn from 'wait-on'; import { ROOT_DIRECTORY, SANDBOX_DIRECTORY } from './utils/constants'; import { exec } from './utils/exec'; process.setMaxListeners(50); ...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/knip.config.ts
scripts/knip.config.ts
import { join, relative } from 'node:path'; import { pathToFileURL } from 'node:url'; // eslint-disable-next-line depend/ban-dependencies import fg from 'fast-glob'; import type { KnipConfig } from 'knip'; import { match } from 'minimatch'; // Files we want to exclude from analysis should be negated project patterns,...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/combine-compodoc.ts
scripts/combine-compodoc.ts
// Compodoc does not follow symlinks (it ignores them and their contents entirely) // So, we need to run a separate compodoc process on every symlink inside the project, // then combine the results into one large documentation.json import { lstat, readFile, realpath, writeFile } from 'node:fs/promises'; // eslint-disa...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/build-package.ts
scripts/build-package.ts
/** * This is the entrypoint for when you run: * * @example `nr build storybook --watch` * * You can pass a list of package names to build, or use the `--all` flag to build all packages. * * Pass the `--watch` flag to build in watch mode or `--no-watch` to skip the watch mode prompt. * * Pass the `--prod` flag...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false
storybookjs/storybook
https://github.com/storybookjs/storybook/blob/7f193d38eec36246a211339c1f352cca246de779/scripts/event-log-collector.ts
scripts/event-log-collector.ts
import { json } from '@polka/parse'; import polka from 'polka'; const PORT = process.env.PORT || 6007; const server = polka(); server.use(json()); const events: Record<string, unknown>[] = []; server.post('/event-log', (req, res) => { console.log(`Received event ${req.body.eventType}`); events.push(req.body); ...
typescript
MIT
7f193d38eec36246a211339c1f352cca246de779
2026-01-04T15:25:31.846427Z
false