import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import type { AnyAction } from 'redux'; import { describe, expect, it, vi } from 'vitest'; import { memo } from '@wordpress/element'; import withDispatch from '../'; import { createRegistry } from '../../../registry'; import { RegistryProvider } from '../../registry-provider'; describe( 'withDispatch', () => { const storeOptions = { reducer: ( state = 0, action: AnyAction ) => { if ( action.type === 'inc' ) { return state + action.count; } return state; }, actions: { increment: ( count = 1 ) => ( { type: 'inc', count } ), }, selectors: { getCount: ( state: number ) => state, }, }; it( 'passes the relevant data to the component', async () => { const user = userEvent.setup(); const registry = createRegistry(); registry.registerStore( 'counter', storeOptions ); const ButtonSpy = vi.fn( ( { onClick } ) => (