Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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