Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Fix incorrect nesting after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
opr committed May 31, 2023
1 parent d7d0e63 commit 97e3a32
Showing 1 changed file with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,34 @@ describe( 'Proceed to checkout block', () => {
);
//@todo When https://github.com/WordPress/gutenberg/issues/22850 is complete use that new matcher here for more specific error message assertion.
expect( console ).toHaveErrored();
it( 'dispatches the onProceedToCheckout event when the button is clicked', async () => {
const mockObserver = jest.fn();
const MockObserverComponent = () => {
const { onProceedToCheckout } = useCartEventsContext();
useEffect( () => {
return onProceedToCheckout( mockObserver );
}, [ onProceedToCheckout ] );
return <div>Mock observer</div>;
};
} );
it( 'dispatches the onProceedToCheckout event when the button is clicked', async () => {
const mockObserver = jest.fn();
const MockObserverComponent = () => {
const { onProceedToCheckout } = useCartEventsContext();
useEffect( () => {
return onProceedToCheckout( mockObserver );
}, [ onProceedToCheckout ] );
return <div>Mock observer</div>;
};

render(
<CartEventsProvider>
<div>
<MockObserverComponent />
<Block
buttonLabel={ 'Proceed to checkout' }
checkoutPageId={ 0 }
className="test-block"
/>
</div>
</CartEventsProvider>
);
expect( screen.getByText( 'Mock observer' ) ).toBeInTheDocument();
const button = screen.getByText( 'Proceed to Checkout' );
button.click();
await waitFor( () => {
expect( mockObserver ).toHaveBeenCalled();
} );
render(
<CartEventsProvider>
<div>
<MockObserverComponent />
<Block
buttonLabel={ 'Proceed to Checkout' }
checkoutPageId={ 0 }
className="test-block"
/>
</div>
</CartEventsProvider>
);
expect( screen.getByText( 'Mock observer' ) ).toBeInTheDocument();
const button = screen.getByText( 'Proceed to Checkout' );
button.click();
await waitFor( () => {
expect( mockObserver ).toHaveBeenCalled();
} );
} );
} );

0 comments on commit 97e3a32

Please sign in to comment.