Add JS unit test to ensure local pickup title is read from settings

This commit is contained in:
Thomas Roberts 2024-09-19 16:22:46 +01:00
parent ad1fb11d0d
commit b6a607b017
No known key found for this signature in database
GPG Key ID: 0262BEBCBE336365
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
/**
* External dependencies
*/
import { render } from '@testing-library/react';
/**
* Internal dependencies
*/
import Block from '../block';
jest.mock( '@woocommerce/settings', () => {
return {
...jest.requireActual( '@woocommerce/settings' ),
getSetting: jest.fn().mockImplementation( ( key, defaultValue ) => {
if ( key === 'localPickupText' ) {
return 'Pickup text from settings';
}
return defaultValue;
} ),
};
} );
describe( 'Block', () => {
it( 'Renders the local pickup text from options', async () => {
const { getByText } = render(
<Block
localPickupText="backup local pickup text"
onChange={ () => void 0 }
showIcon={ false }
showPrice={ false }
checked={ 'shipping' }
shippingText="backup shipping text"
/>
);
expect( getByText( 'Pickup text from settings' ) ).toBeInTheDocument();
} );
} );