diff --git a/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/test/block.tsx b/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/test/block.tsx new file mode 100644 index 00000000000..72634a7877f --- /dev/null +++ b/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/test/block.tsx @@ -0,0 +1,40 @@ +/** + * External dependencies + */ +import { render, screen, waitFor } from '@testing-library/react'; +import { useCartEventsContext } from '@woocommerce/base-context'; +import { useEffect } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import Block from '../block'; +import { CartEventsProvider } from '../../../../../base/context/providers'; + +describe( 'ProceedToCheckoutBlock', () => { + 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