403Webshell
Server IP : 172.67.158.161  /  Your IP : 18.118.198.127
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/root/home/giankuin/sieuthiweb.com.vn/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/data/cart/test/reducers.js
/**
 * External dependencies
 */
import deepFreeze from 'deep-freeze';

/**
 * Internal dependencies
 */
import cartReducer from '../reducers';
import { ACTION_TYPES as types } from '../action-types';

describe( 'cartReducer', () => {
	const originalState = deepFreeze( {
		cartData: {
			coupons: [],
			items: [],
			itemsCount: 0,
			itemsWeight: 0,
			needsShipping: true,
			totals: {},
		},
		metaData: {},
		errors: [
			{
				code: '100',
				message: 'Test Error',
				data: {},
			},
		],
	} );
	it( 'sets expected state when a cart is received', () => {
		const testAction = {
			type: types.RECEIVE_CART,
			response: {
				coupons: [],
				items: [],
				itemsCount: 0,
				itemsWeight: 0,
				needsShipping: true,
				totals: {},
			},
		};
		const newState = cartReducer( originalState, testAction );
		expect( newState ).not.toBe( originalState );
		expect( newState.cartData ).toEqual( {
			coupons: [],
			items: [],
			itemsCount: 0,
			itemsWeight: 0,
			needsShipping: true,
			totals: {},
		} );
	} );
	it( 'sets expected state when errors are replaced', () => {
		const testAction = {
			type: types.REPLACE_ERRORS,
			error: {
				code: '101',
				message: 'Test Error',
				data: {},
			},
		};
		const newState = cartReducer( originalState, testAction );
		expect( newState ).not.toBe( originalState );
		expect( newState.errors ).toEqual( [
			{
				code: '101',
				message: 'Test Error',
				data: {},
			},
		] );
	} );
	it( 'sets expected state when an error is added', () => {
		const testAction = {
			type: types.RECEIVE_ERROR,
			error: {
				code: '101',
				message: 'Test Error',
				data: {},
			},
		};
		const newState = cartReducer( originalState, testAction );
		expect( newState ).not.toBe( originalState );
		expect( newState.errors ).toEqual( [
			{
				code: '100',
				message: 'Test Error',
				data: {},
			},
			{
				code: '101',
				message: 'Test Error',
				data: {},
			},
		] );
	} );
	it( 'sets expected state when a coupon is applied', () => {
		const testAction = {
			type: types.APPLYING_COUPON,
			couponCode: 'APPLYME',
		};
		const newState = cartReducer( originalState, testAction );
		expect( newState ).not.toBe( originalState );
		expect( newState.metaData.applyingCoupon ).toEqual( 'APPLYME' );
	} );
	it( 'sets expected state when a coupon is removed', () => {
		const testAction = {
			type: types.REMOVING_COUPON,
			couponCode: 'REMOVEME',
		};
		const newState = cartReducer( originalState, testAction );
		expect( newState ).not.toBe( originalState );
		expect( newState.metaData.removingCoupon ).toEqual( 'REMOVEME' );
	} );
} );

Youez - 2016 - github.com/yon3zu
LinuXploit