import React from "react"; declare type AnyFunction = (...args: any) => any; export declare type AnyHook = AnyFunction; export declare type OverridableHook = THook & { /** * This property is used to identify an overridable hook. * It also holds the name of the actual raw hook (if supplied) for debugging purposes. */ isOverridableHook: string; }; /** * This Provider allows us to override any of the registered hooks. * * Each hook override should match the original hook signature. * * If needed, add the `help` or `help='warn'` property to help identify which hooks can be overridden. */ declare type HookOverridesProps = { /** * When true, an error will be thrown for any overridable hooks that are not mocked. * This makes it easy to find overridable hooks. * Once all overridable hooks are mocked, the `help` prop can be removed. * * "warn" will simply log to the console, instead of throwing an error. */ help?: boolean | "warn" | "error"; } & { [P in keyof THookOverrides]?: THookOverrides[P] extends OverridableHook ? THook | null : never; }; export declare type HookOverridesBase = { /** * A list of all hooks that can be overridden by this provider */ [propName: string]: OverridableHook; }; /** * Creates a HookOverridesProvider which can be used to override hooks. * * @example * const HookOverrides = createHookOverridesProvider({ useCounter, useToggle }); * const Example = () => ( * ({ count: 99 })} * useToggle={() => ({ toggled: true })} * > * * ; * ); * * @param hooksToOverride An object that lists all hooks which this provider should be able to override. * These hooks must have been wrapped with `testableHook` or `overridableHook`. * @param options */ export declare function createHookOverridesProvider(hooksToOverride: THookOverrides, options?: { defaults?: HookOverridesProps; }): React.FC>; export declare type TestableHookOptions = { /** * If false, the hook will be passed through untouched. * * Default is true for the following environments: * - NODE_ENV=test (the default for Jest) * - STORYBOOK=true (the default for Storybook) * - TESTABLE_HOOKS_ENABLED=true (manually set by you) */ enabled?: boolean; }; /** * Wraps a hook, so that it can be optionally overridden. * * By default, the returned wrapper is identical to the hook, and should be used in its place. * However, a HookOverridesProvider can be used to override the hook. * * This is especially useful for mocking, for tests, or for Storybook integration. * * For non-test environments, there is no overhead; the original hook will be passed-through verbatim. * * @param hook - Any hook-like function * @param [options] - Default: { enabled: NODE_ENV === 'test' || STORYBOOK === 'true' || TESTABLE_HOOKS_ENABLED === 'true' } */ export declare function testableHook(hook: THook, { enabled, }?: TestableHookOptions): OverridableHook; /** * Wraps a hook, so that it can be optionally overridden. * * By default, the returned wrapper is identical to the hook, and should be used in its place. * However, a HookOverridesProvider can be used to override the hook. * * This is especially useful for mocking, for tests, or for Storybook integration. * * @param hook - Any hook-like function */ export declare function overridableHook(hook: THook): OverridableHook; export {};