403Webshell
Server IP : 104.21.14.103  /  Your IP : 3.23.102.165
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/utils.js
/**
 * Internal dependencies
 */
import {
	extractResourceNameFromRoute,
	getRouteIds,
	simplifyRouteWithId,
} from '../utils';

describe( 'extractResourceNameFromRoute', () => {
	it.each`
		namespace      | route                                                                          | expected
		${'wc/blocks'} | ${'wc/blocks/products'}                                                        | ${'products'}
		${'wc/other'}  | ${'wc/blocks/product'}                                                         | ${'wc/blocks/product'}
		${'wc/blocks'} | ${'wc/blocks/products/attributes/(?P<attribute_id>[\\d]+)'}                    | ${'products/attributes'}
		${'wc/blocks'} | ${'wc/blocks/products/attributes/(?P<attribute_id>[\\d]+)/terms'}              | ${'products/attributes/terms'}
		${'wc/blocks'} | ${'wc/blocks/products/attributes/(?P<attribute_id>[\\d]+)/terms/(?P<id>[d]+)'} | ${'products/attributes/terms'}
	`(
		'returns "$expected" when namespace is "$namespace" and route is "$route"',
		( { namespace, route, expected } ) => {
			expect( extractResourceNameFromRoute( namespace, route ) ).toBe(
				expected
			);
		}
	);
} );

describe( 'getRouteIds', () => {
	it.each`
		route                                                                            | expected
		${'wc/blocks/products'}                                                          | ${[]}
		${'wc/blocks/products/(?P<id>[\\d]+)'}                                           | ${[ 'id' ]}
		${'wc/blocks/products/attributes/(?P<attribute_id>[\\d]+)/terms/(?P<id>[\\d]+)'} | ${[ 'attribute_id', 'id' ]}
	`(
		'returns "$expected" when route is "$route"',
		( { route, expected } ) => {
			expect( getRouteIds( route ) ).toEqual( expected );
		}
	);
} );

describe( 'simplifyRouteWithId', () => {
	it.each`
		route                                                                            | matchIds                    | expected
		${'wc/blocks/products'}                                                          | ${[]}                       | ${'wc/blocks/products'}
		${'wc/blocks/products/attributes/(?P<attribute_id>[\\d]+)'}                      | ${[ 'attribute_id' ]}       | ${'wc/blocks/products/attributes/{attribute_id}'}
		${'wc/blocks/products/attributes/(?P<attribute_id>[\\d]+)/terms'}                | ${[ 'attribute_id' ]}       | ${'wc/blocks/products/attributes/{attribute_id}/terms'}
		${'wc/blocks/products/attributes/(?P<attribute_id>[\\d]+)/terms/(?P<id>[\\d]+)'} | ${[ 'attribute_id', 'id' ]} | ${'wc/blocks/products/attributes/{attribute_id}/terms/{id}'}
		${'wc/blocks/products/attributes/(?P<attribute_id>[\\d]+)/terms/(?P<id>[\\d]+)'} | ${[ 'id', 'attribute_id' ]} | ${'wc/blocks/products/attributes/{attribute_id}/terms/{id}'}
	`(
		'returns "$expected" when route is "$route" and matchIds is "$matchIds"',
		( { route, matchIds, expected } ) => {
			expect( simplifyRouteWithId( route, matchIds ) ).toBe( expected );
		}
	);
} );

Youez - 2016 - github.com/yon3zu
LinuXploit