403Webshell
Server IP : 104.21.14.103  /  Your IP : 3.141.31.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/query-state/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/query-state/test/selectors.js
/**
 * External dependencies
 */
import deepFreeze from 'deep-freeze';

/**
 * Internal dependencies
 */
import { getValueForQueryKey, getValueForQueryContext } from '../selectors';

const testState = deepFreeze( {
	contexta: JSON.stringify( {
		foo: 'bar',
		cheese: 'pizza',
	} ),
} );

describe( 'getValueForQueryKey', () => {
	it(
		'returns provided default value when there is no state for the ' +
			'given context',
		() => {
			expect(
				getValueForQueryKey( testState, 'invalid', 'foo', 42 )
			).toBe( 42 );
		}
	);
	it(
		'returns provided default value when there is no value for the ' +
			'given context and queryKey',
		() => {
			expect(
				getValueForQueryKey( testState, 'contexta', 'pizza', 42 )
			).toBe( 42 );
		}
	);
	it( 'returns expected value when context and queryKey exist', () => {
		expect( getValueForQueryKey( testState, 'contexta', 'foo', 42 ) ).toBe(
			'bar'
		);
	} );
} );

describe( 'getValueForQueryContext', () => {
	it(
		'returns provided default value when there is no state for the ' +
			'given context',
		() => {
			expect( getValueForQueryContext( testState, 'invalid', 42 ) ).toBe(
				42
			);
		}
	);
	it(
		'returns expected value when selecting a context that exists in ' +
			'state',
		() => {
			expect(
				getValueForQueryContext( testState, 'contexta', 42 )
			).toEqual( JSON.parse( testState.contexta ) );
		}
	);
} );

Youez - 2016 - github.com/yon3zu
LinuXploit