Download frontend/src/components/ui/slider.test.tsx from new-arc/vector: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/spaces/new-arc/vector/resolve/main/frontend/src/components/ui/slider.test.tsx
- Command line
-
hf download hf://spaces/new-arc/vector/frontend/src/components/ui/slider.test.tsx
-
curl -L -o slider.test.tsx https://huggingface.co/spaces/new-arc/vector/resolve/main/frontend/src/components/ui/slider.test.tsx
811 Bytes
| import { fireEvent, render, screen } from "@testing-library/react"; | |
| import { afterEach, expect, it, vi } from "vitest"; | |
| import { Slider } from "./slider"; | |
| afterEach(() => vi.unstubAllGlobals()); | |
| it("exposes both range endpoints and lets the keyboard adjust the end", () => { | |
| vi.stubGlobal("ResizeObserver", class { observe() {} unobserve() {} disconnect() {} }); | |
| const onChange = vi.fn(); | |
| render(<Slider aria-label="Trim range" min={0} max={10} step={1} defaultValue={[2, 8]} onValueChange={onChange} />); | |
| expect(screen.getByRole("slider", { name: "Trim range start" })).toHaveAttribute("aria-valuenow", "2"); | |
| const end = screen.getByRole("slider", { name: "Trim range end" }); | |
| end.focus(); | |
| fireEvent.keyDown(end, { key: "ArrowRight" }); | |
| expect(onChange).toHaveBeenLastCalledWith([2, 9]); | |
| }); | |