Server IP : 172.67.158.161 / Your IP : 3.145.88.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/schema/test/ |
Upload File : |
/** * 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', ], }, }, } ); } ); } );