Server IP : 104.21.14.103 / Your IP : 18.221.56.241 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/thread-self/root/home/giankuin/sieuthiweb.com.vn/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/data/cart/test/ |
Upload File : |
/** * Internal dependencies */ import { getCartData } from '../resolvers'; import { receiveCart, receiveError } from '../actions'; import { CART_API_ERROR } from '../constants'; jest.mock( '@wordpress/data-controls' ); describe( 'getCartData', () => { describe( 'yields with expected responses', () => { let fulfillment; const rewind = () => ( fulfillment = getCartData() ); test( 'when apiFetch returns a valid response, yields expected ' + 'action', () => { rewind(); fulfillment.next( 'https://example.org' ); const { value } = fulfillment.next( { coupons: [], items: [], itemsCount: 0, itemsWeight: 0, needsShipping: true, totals: {}, } ); expect( value ).toEqual( receiveCart( { coupons: [], items: [], itemsCount: 0, itemsWeight: 0, needsShipping: true, totals: {}, } ) ); const { done } = fulfillment.next(); expect( done ).toBe( true ); } ); } ); describe( 'yields with expected response when there is an error', () => { let fulfillment; const rewind = () => ( fulfillment = getCartData() ); test( 'when apiFetch returns a valid response, yields expected ' + 'action', () => { rewind(); fulfillment.next( 'https://example.org' ); const { value } = fulfillment.next( undefined ); expect( value ).toEqual( receiveError( CART_API_ERROR ) ); const { done } = fulfillment.next(); expect( done ).toBe( true ); } ); } ); } );