feat(react): add slider component (#644)

This commit is contained in:
rahim
2026-02-28 00:48:51 -08:00
committed by GitHub
parent e63d591d6e
commit 2f8ca094ad
21 changed files with 1276 additions and 12 deletions
+46
View File
@@ -0,0 +1,46 @@
/**
* Shared test helpers for `@videojs/react`.
*
* Provides factory functions for common mock objects used across component
* tests. `vi.mock()` blocks must still live in each test file (Vitest hoists
* them before imports), but non-mock helpers like store and wrapper factories
* can be shared here.
*/
import type { ReactNode } from 'react';
import { vi } from 'vitest';
import { PlayerContextProvider, type PlayerContextValue } from '../player/context';
/**
* Create a minimal mock store compatible with `PlayerContextValue`.
*
* Pass optional `state` to seed the store's state snapshot.
*/
export function createMockStore(state: Record<string, unknown> = {}) {
return {
state,
attach: vi.fn(() => vi.fn()),
subscribe: vi.fn(() => vi.fn()),
destroy: vi.fn(),
};
}
/**
* Create a React wrapper that provides `PlayerContextProvider`.
*
* Accepts an optional store state seed. Returns the wrapper component,
* the mock store, and the context value for assertions.
*/
export function createPlayerWrapper(storeState: Record<string, unknown> = {}) {
const store = createMockStore(storeState);
const value: PlayerContextValue = { store: store as any, media: null, setMedia: vi.fn() };
return {
store,
value,
Wrapper({ children }: { children: ReactNode }) {
return <PlayerContextProvider value={value}>{children}</PlayerContextProvider>;
},
};
}