mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
chore: upgrade typescript 6, vitest 4, align spf package (#1101)
This commit is contained in:
@@ -8,16 +8,24 @@
|
||||
*/
|
||||
|
||||
import type { ReactNode } from 'react';
|
||||
import type { Mock } from 'vitest';
|
||||
import { vi } from 'vitest';
|
||||
|
||||
import { PlayerContextProvider, type PlayerContextValue } from '../player/context';
|
||||
|
||||
interface MockStore {
|
||||
state: Record<string, unknown>;
|
||||
attach: Mock<() => Mock>;
|
||||
subscribe: Mock<() => Mock>;
|
||||
destroy: Mock;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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> = {}) {
|
||||
export function createMockStore(state: Record<string, unknown> = {}): MockStore {
|
||||
return {
|
||||
state,
|
||||
attach: vi.fn(() => vi.fn()),
|
||||
@@ -32,7 +40,11 @@ export function createMockStore(state: Record<string, unknown> = {}) {
|
||||
* 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> = {}) {
|
||||
export function createPlayerWrapper(storeState: Record<string, unknown> = {}): {
|
||||
store: MockStore;
|
||||
value: PlayerContextValue;
|
||||
Wrapper: ({ children }: { children: ReactNode }) => ReactNode;
|
||||
} {
|
||||
const store = createMockStore(storeState);
|
||||
const value: PlayerContextValue = {
|
||||
store: store as any,
|
||||
|
||||
Reference in New Issue
Block a user