403Webshell
Server IP : 172.67.158.161  /  Your IP : 18.119.131.235
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/blocks/cart/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/blocks/cart/test/slots.js
/* eslint-disable jest/no-commented-out-tests */
/**
 * External dependencies
 */
import { render, screen, waitFor, act } from '@testing-library/react';
import { previewCart } from '@woocommerce/resource-previews';
import { dispatch } from '@wordpress/data';
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
import { default as fetchMock } from 'jest-fetch-mock';
import { ExperimentalOrderMeta } from '@woocommerce/blocks-checkout';
import { registerPlugin } from '@wordpress/plugins';
/**
 * Internal dependencies
 */
import { defaultCartState } from '../../../data/cart/default-state';

import Cart from '../block';
import OrderSummaryBlock from '../inner-blocks/cart-order-summary-block/frontend';

const SlotFillConsumer = ( { cart } ) => {
	const { billingData } = cart;

	return <p>My address: { billingData.address_1 }</p>;
};

const CartBlock = () => {
	return (
		<Cart>
			<OrderSummaryBlock />
		</Cart>
	);
};

describe( 'Testing Slotfills', () => {
	beforeAll( () => {
		registerPlugin( 'slot-fills-test', {
			render: () => (
				<ExperimentalOrderMeta>
					<SlotFillConsumer />
				</ExperimentalOrderMeta>
			),
			scope: 'woocommerce-checkout',
		} );
	} );
	beforeEach( () => {
		act( () => {
			fetchMock.mockResponse( ( req ) => {
				if ( req.url.match( /wc\/store\/v1\/cart/ ) ) {
					return Promise.resolve( JSON.stringify( previewCart ) );
				}
				return Promise.resolve( '' );
			} );
			// need to clear the store resolution state between tests.
			dispatch( storeKey ).invalidateResolutionForStore();
			dispatch( storeKey ).receiveCart( defaultCartState.cartData );
		} );
	} );

	afterEach( () => {
		fetchMock.resetMocks();
	} );

	it( 'still expects billingData', async () => {
		fetchMock.mockResponse( ( req ) => {
			if ( req.url.match( /wc\/store\/v1\/cart/ ) ) {
				const cart = {
					...previewCart,
					billing_address: {
						...previewCart.billing_address,
						address_1: 'Street address',
					},
				};

				return Promise.resolve( JSON.stringify( cart ) );
			}
		} );
		render( <CartBlock /> );
		await waitFor( () => expect( fetchMock ).toHaveBeenCalled() );

		expect(
			screen.getByText( /My address: Street address/i )
		).toBeInTheDocument();

		expect( fetchMock ).toHaveBeenCalledTimes( 1 );
	} );
} );

Youez - 2016 - github.com/yon3zu
LinuXploit