403Webshell
Server IP : 104.21.14.103  /  Your IP : 3.17.74.148
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 :  /home/giankuin/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/data/schema/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/giankuin/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/data/schema/test/reducers.js
/**
 * External dependencies
 */
import deepFreeze from 'deep-freeze';

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

describe( 'receiveRoutes', () => {
	it( 'returns original state when action type is not a match', () => {
		expect( receiveRoutes( undefined, { type: 'invalid' } ) ).toEqual( {} );
	} );
	it( 'returns original state when the given endpoints already exists', () => {
		const routes = [
			'wc/blocks/products/attributes',
			'wc/blocks/products/attributes/(?P<attribute_id>[d]+)/terms/(?P<id>[d]+)',
		];
		const originalState = deepFreeze( {
			'wc/blocks': {
				'products/attributes': {
					'wc/blocks/products/attributes': [],
				},
				'products/attributes/terms': {
					'wc/blocks/products/attributes/{attribute_id}/terms/{id}': [
						'attribute_id',
						'id',
					],
				},
			},
		} );
		const newState = receiveRoutes( originalState, {
			type: types.RECEIVE_MODEL_ROUTES,
			namespace: 'wc/blocks',
			routes,
		} );
		expect( newState ).toBe( originalState );
	} );
	it( 'returns expected state when new route added', () => {
		const action = {
			type: types.RECEIVE_MODEL_ROUTES,
			namespace: 'wc/blocks',
			routes: [ 'wc/blocks/products/attributes' ],
		};
		const originalState = deepFreeze( {
			'wc/blocks': {
				'products/attributes/terms': {
					'wc/blocks/products/attributes/{attribute_id}/terms/{id}': [
						'attribute_id',
						'id',
					],
				},
			},
		} );
		const newState = receiveRoutes( originalState, action );
		expect( newState ).not.toBe( originalState );
		expect( newState ).toEqual( {
			'wc/blocks': {
				'products/attributes': {
					'wc/blocks/products/attributes': [],
				},
				'products/attributes/terms': {
					'wc/blocks/products/attributes/{attribute_id}/terms/{id}': [
						'attribute_id',
						'id',
					],
				},
			},
		} );
	} );
} );

Youez - 2016 - github.com/yon3zu
LinuXploit