Skip to content

Commit f491ce5

Browse files
authored
fix js test console warning (#4242)
1 parent d6549c8 commit f491ce5

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

client/settings/display-order-customization-notice/__tests__/display-order-customization-notice.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe( 'DisplayOrderCustomizationNotice', () => {
3737
expect( noticeText ).toBeInTheDocument();
3838
} );
3939

40-
it( 'should make an API call to dismiss the banner on button click', () => {
40+
it( 'should make an API call to dismiss the banner on button click', async () => {
4141
const dismissNoticeMock = jest.fn( () =>
4242
Promise.resolve( { data: {} } )
4343
);
@@ -53,8 +53,8 @@ describe( 'DisplayOrderCustomizationNotice', () => {
5353
'aria-label': 'Dismiss the notice',
5454
} );
5555
expect( dismissButton ).toBeInTheDocument();
56-
act( () => {
57-
userEvent.click( dismissButton );
56+
await act( async () => {
57+
await userEvent.click( dismissButton );
5858
} );
5959
expect( dismissNoticeMock ).toHaveBeenCalled();
6060
} );

client/settings/payment-settings/__tests__/promotional-banner-section.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,23 @@ const setShowPromotionalBanner = jest.fn();
3737
const setPromotionalBannerType = jest.fn();
3838

3939
describe( 'PromotionalBanner', () => {
40+
// Keep the original function.
41+
const reload = window.location.reload;
4042
beforeEach( () => {
43+
Object.defineProperty( window, 'location', {
44+
value: { reload: jest.fn() },
45+
} );
4146
global.wc_stripe_settings_params = { are_apms_deprecated: false };
4247
} );
4348

49+
afterEach( () => {
50+
// Set the original function back to keep further tests working as expected.
51+
Object.defineProperty( window, 'location', {
52+
value: { reload },
53+
} );
54+
jest.restoreAllMocks();
55+
} );
56+
4457
it( 'dismiss function should be called', () => {
4558
render(
4659
<PromotionalBannerSection

0 commit comments

Comments
 (0)