Skip to content

Commit

Permalink
Adjust tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia committed Jan 10, 2025
1 parent 9c2caba commit 8e23dc8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
14 changes: 7 additions & 7 deletions packages/block-library/src/cover/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function setup( attributes, useCoreBlocks, customSettings ) {
async function createAndSelectBlock() {
await userEvent.click(
screen.getByRole( 'option', {
name: 'Color: Black',
name: 'Black',
} )
);
await userEvent.click(
Expand All @@ -73,7 +73,7 @@ describe( 'Cover block', () => {
test( 'can set overlay color using color picker on block placeholder', async () => {
const { container } = await setup();
const colorPicker = screen.getByRole( 'option', {
name: 'Color: Black',
name: 'Black',
} );
await userEvent.click( colorPicker );
const color = colorPicker.style.backgroundColor;
Expand All @@ -97,7 +97,7 @@ describe( 'Cover block', () => {

await userEvent.click(
screen.getByRole( 'option', {
name: 'Color: Black',
name: 'Black',
} )
);

Expand Down Expand Up @@ -390,7 +390,7 @@ describe( 'Cover block', () => {
test( 'should toggle is-light class if background changed from light to dark', async () => {
await setup();
const colorPicker = screen.getByRole( 'option', {
name: 'Color: White',
name: 'White',
} );
await userEvent.click( colorPicker );

Expand All @@ -406,15 +406,15 @@ describe( 'Cover block', () => {
);
await userEvent.click( screen.getByText( 'Overlay' ) );
const popupColorPicker = screen.getByRole( 'option', {
name: 'Color: Black',
name: 'Black',
} );
await userEvent.click( popupColorPicker );
expect( coverBlock ).not.toHaveClass( 'is-light' );
} );
test( 'should remove is-light class if overlay color is removed', async () => {
await setup();
const colorPicker = screen.getByRole( 'option', {
name: 'Color: White',
name: 'White',
} );
await userEvent.click( colorPicker );
const coverBlock = screen.getByLabelText( 'Block: Cover' );
Expand All @@ -429,7 +429,7 @@ describe( 'Cover block', () => {
// The default color is black, so clicking the black color option will remove the background color,
// which should remove the isDark setting and assign the is-light class.
const popupColorPicker = screen.getByRole( 'option', {
name: 'Color: White',
name: 'White',
} );
await userEvent.click( popupColorPicker );
expect( coverBlock ).not.toHaveClass( 'is-light' );
Expand Down
16 changes: 12 additions & 4 deletions packages/components/src/border-control/test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/**
* External dependencies
*/
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import {
fireEvent,
render,
screen,
waitFor,
within,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

/**
Expand Down Expand Up @@ -56,7 +62,7 @@ const getButton = ( name ) => {
};

const getColorOption = ( color ) => {
return screen.getByRole( 'option', { name: `Color: ${ color }` } );
return screen.getByRole( 'option', { name: `${ color }` } );
};

const queryButton = ( name ) => {
Expand Down Expand Up @@ -131,9 +137,11 @@ describe( 'BorderControl', () => {
await openPopover( user );

const customColorPicker = getButton( /Custom color picker/ );
const colorSwatchButtons = screen.getAllByRole( 'option', {
name: /^Color:/,
const circularOptionPicker = screen.getByRole( 'listbox', {
name: 'Custom color picker.',
} );
const colorSwatchButtons =
within( circularOptionPicker ).getAllByRole( 'option' );
const styleLabel = screen.getByText( 'Style' );
const solidButton = getButton( 'Solid' );
const dashedButton = getButton( 'Dashed' );
Expand Down

0 comments on commit 8e23dc8

Please sign in to comment.