<commit_before>/**
 * Property Select component tests.
 *
 * Site Kit by Google, Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * WordPress dependencies
 */
import apiFetchMock from '@wordpress/api-fetch';

/**
 * Internal dependencies
 */
import PropertySelect from './property-select';
import { STORE_NAME, ACCOUNT_CREATE } from '../datastore/constants';
import * as fixtures from '../datastore/__fixtures__';
import { fireEvent, render, act } from '../../../../../tests/js/test-utils';

// Mock apiFetch so we know if it's called.
jest.mock( '@wordpress/api-fetch' );
apiFetchMock.mockImplementation( ( ...args ) => {
	// eslint-disable-next-line no-console
	console.warn( 'apiFetch', ...args );
} );

const setupRegistry = ( { dispatch } ) => {
	const accountID = fixtures.accountsPropertiesProfiles.properties[ 0 ].accountId;
	dispatch( STORE_NAME ).setAccountID( accountID );
	dispatch( STORE_NAME ).receiveGetProperties( fixtures.accountsPropertiesProfiles.properties, { accountID } );
	dispatch( STORE_NAME ).receiveGetExistingTag( null );
};

const setupRegistryWithExistingTag = ( { dispatch } ) => {
	const accountID = fixtures.accountsPropertiesProfiles.properties[ 0 ].accountId;
	dispatch( STORE_NAME ).receiveGetProperties( fixtures.accountsPropertiesProfiles.properties, { accountID } );
	dispatch( STORE_NAME ).receiveGetExistingTag( fixtures.getTagPermissionsAccess );
	// Existing tag IDs are set in the resolver so we have to fill those here.
	dispatch( STORE_NAME ).setAccountID( fixtures.getTagPermissionsAccess.accountID );
	dispatch( STORE_NAME ).setPropertyID( fixtures.getTagPermissionsAccess.propertyID );
};

const setupEmptyRegistry = ( { dispatch } ) => {<commit_msg>Fix receiveGetExistingTag in PropertySelect test.<commit_after>/**
 * Property Select component tests.
 *
 * Site Kit by Google, Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * WordPress dependencies
 */
import apiFetchMock from '@wordpress/api-fetch';

/**
 * Internal dependencies
 */
import PropertySelect from './property-select';
import { STORE_NAME, ACCOUNT_CREATE } from '../datastore/constants';
import * as fixtures from '../datastore/__fixtures__';
import { fireEvent, render, act } from '../../../../../tests/js/test-utils';

// Mock apiFetch so we know if it's called.
jest.mock( '@wordpress/api-fetch' );
apiFetchMock.mockImplementation( ( ...args ) => {
	// eslint-disable-next-line no-console
	console.warn( 'apiFetch', ...args );
} );

const setupRegistry = ( { dispatch } ) => {
	const accountID = fixtures.accountsPropertiesProfiles.properties[ 0 ].accountId;
	dispatch( STORE_NAME ).setAccountID( accountID );
	dispatch( STORE_NAME ).receiveGetProperties( fixtures.accountsPropertiesProfiles.properties, { accountID } );
	dispatch( STORE_NAME ).receiveGetExistingTag( null );
};

const setupRegistryWithExistingTag = ( { dispatch } ) => {
	const accountID = fixtures.accountsPropertiesProfiles.properties[ 0 ].accountId;
	dispatch( STORE_NAME ).receiveGetProperties( fixtures.accountsPropertiesProfiles.properties, { accountID } );
	dispatch( STORE_NAME ).receiveGetExistingTag( fixtures.getTagPermissionsAccess.propertyID );
	// Existing tag IDs are set in the resolver so we have to fill those here.
	dispatch( STORE_NAME ).setAccountID( fixtures.getTagPermissionsAccess.accountID );
	dispatch( STORE_NAME ).setPropertyID( fixtures.getTagPermissionsAccess.propertyID );
};

const setupEmptyRegistry = ( { dispatch } ) => {
{'fraction_non_alphanumeric': 0.11505400044081993, 'fraction_numerical': 0.004408199250606128, 'mean_word_length': 4.4873035066505444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4937293', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1230, 'n_words': 404}