Skip to content

Fix JS test console warning #4242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe( 'DisplayOrderCustomizationNotice', () => {
expect( noticeText ).toBeInTheDocument();
} );

it( 'should make an API call to dismiss the banner on button click', () => {
it( 'should make an API call to dismiss the banner on button click', async () => {
const dismissNoticeMock = jest.fn( () =>
Promise.resolve( { data: {} } )
);
Expand All @@ -53,8 +53,8 @@ describe( 'DisplayOrderCustomizationNotice', () => {
'aria-label': 'Dismiss the notice',
} );
expect( dismissButton ).toBeInTheDocument();
act( () => {
userEvent.click( dismissButton );
await act( async () => {
await userEvent.click( dismissButton );
} );
expect( dismissNoticeMock ).toHaveBeenCalled();
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,23 @@ const setShowPromotionalBanner = jest.fn();
const setPromotionalBannerType = jest.fn();

describe( 'PromotionalBanner', () => {
// Keep the original function.
const reload = window.location.reload;
beforeEach( () => {
Object.defineProperty( window, 'location', {
value: { reload: jest.fn() },
} );
global.wc_stripe_settings_params = { are_apms_deprecated: false };
} );

afterEach( () => {
// Set the original function back to keep further tests working as expected.
Object.defineProperty( window, 'location', {
value: { reload },
} );
jest.restoreAllMocks();
} );

it( 'dismiss function should be called', () => {
render(
<PromotionalBannerSection
Expand Down
Loading