Download react-query/packages/solid-query/src/__tests__/utils.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 942 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/solid-query/src/__tests__/utils.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/solid-query/src/__tests__/utils.tsx
-
curl -L -o utils.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/solid-query/src/__tests__/utils.tsx
942 Bytes
| import { vi } from 'vitest' | |
| import { Show, createEffect, createSignal, onCleanup } from 'solid-js' | |
| import { onlineManager } from '@tanstack/query-core' | |
| import type { ParentProps } from 'solid-js' | |
| import type { MockInstance } from 'vitest' | |
| export function Blink( | |
| props: { | |
| duration: number | |
| } & ParentProps, | |
| ) { | |
| const [shouldShow, setShouldShow] = createSignal<boolean>(true) | |
| createEffect(() => { | |
| setShouldShow(true) | |
| const timeout = setActTimeout(() => setShouldShow(false), props.duration) | |
| onCleanup(() => clearTimeout(timeout)) | |
| }) | |
| return ( | |
| <Show when={shouldShow()} fallback={<>off</>}> | |
| <>{props.children}</> | |
| </Show> | |
| ) | |
| } | |
| export function mockOnlineManagerIsOnline( | |
| value: boolean, | |
| ): MockInstance<() => boolean> { | |
| return vi.spyOn(onlineManager, 'isOnline').mockReturnValue(value) | |
| } | |
| export function setActTimeout(fn: () => void, ms?: number) { | |
| return setTimeout(() => { | |
| fn() | |
| }, ms) | |
| } | |