Skip to content

Commit

Permalink
Fix withBlockBinding tests by mocking tracks (#209)
Browse files Browse the repository at this point in the history
Pull request #185 has caused an issue with the withBlockBinding tests, which attempt to use the Tracks API. To resolve this, the Tracks function was mocked.
  • Loading branch information
mehmoodak authored Nov 21, 2024
1 parent 91d7e1c commit 3ad5c50
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ import { REMOTE_DATA_CONTEXT_KEY } from '@/blocks/remote-data-container/config/c
import { withBlockBinding } from '@/blocks/remote-data-container/filters/withBlockBinding';
import { BLOCK_BINDING_SOURCE, PATTERN_OVERRIDES_CONTEXT_KEY } from '@/config/constants';

vi.mock( '@/blocks/remote-data-container/utils/tracks', () => ( {
sendTracksEvent: vi.fn(),
} ) );

// Minimal mocking for WordPress dependencies
vi.mock( '@wordpress/block-editor', () => ( {
InspectorControls: ( { children }: { children: React.ReactNode } ) => (
<div data-testid="inspector-controls">{ children }</div>
),
} ) );

vi.mock( '@wordpress/components', () => ( {
PanelBody: ( { children, title }: { children: React.ReactNode; title: string } ) => (
<div data-testid="panel-body" title={ title }>
{ children }
</div>
),
} ) );

vi.mock( '@/hooks/useEditedPostAttribute', () => ( {
useEditedPostAttribute: () => ( {
postType: '',
Expand Down

0 comments on commit 3ad5c50

Please sign in to comment.