Skip to content

Commit

Permalink
Wait for composite to initialize in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Aug 27, 2024
1 parent 69db97c commit 292c94c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/block-editor/src/components/color-palette/test/control.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render } from '@testing-library/react';
import { render, waitFor, queryByAttribute } from '@testing-library/react';

/**
* Internal dependencies
Expand All @@ -10,9 +10,22 @@ import ColorPaletteControl from '../control';

const noop = () => {};

async function renderAndValidate( ...renderArgs ) {
const view = render( ...renderArgs );
await waitFor( () => {
const activeButton = queryByAttribute(
'data-active-item',
view.baseElement,
'true'
);
expect( activeButton ).not.toBeNull();
} );
return view;
}

describe( 'ColorPaletteControl', () => {
it( 'matches the snapshot', async () => {
const { container } = render(
const { container } = await renderAndValidate(
<ColorPaletteControl
label="Test Color"
value="#f00"
Expand Down

0 comments on commit 292c94c

Please sign in to comment.