rebase code on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:51:46 -04:00
parent b16ad94b69
commit 8f1a2c3a66
2197 changed files with 184921 additions and 35568 deletions

View File

@@ -6,24 +6,13 @@
*/
import TestRenderer, { act } from 'react-test-renderer';
import * as mockUtils from '@woocommerce/editor-components/utils';
import { useDebouncedCallback } from 'use-debounce';
import * as mockUseDebounce from 'use-debounce';
/**
* Internal dependencies
*/
import withSearchedProducts from '../with-searched-products';
// Add a mock implementation of debounce for testing so we can spy on the onSearch call.
jest.mock( 'use-debounce', () => {
return {
useDebouncedCallback: jest
.fn()
.mockImplementation(
( search ) => () => mockUtils.getProducts( search )
),
};
} );
jest.mock( '@woocommerce/block-settings', () => ( {
__esModule: true,
blocksConfig: {
@@ -39,10 +28,15 @@ mockUtils.getProducts = jest.fn().mockImplementation( () =>
] )
);
// Add a mock implementation of debounce for testing so we can spy on the onSearch call.
mockUseDebounce.useDebouncedCallback = jest
.fn()
.mockImplementation( ( search ) => () => mockUtils.getProducts( search ) );
describe( 'withSearchedProducts Component', () => {
const { getProducts } = mockUtils;
afterEach( () => {
useDebouncedCallback.mockClear();
mockUseDebounce.useDebouncedCallback.mockClear();
mockUtils.getProducts.mockClear();
} );
const TestComponent = withSearchedProducts(
@@ -83,7 +77,7 @@ describe( 'withSearchedProducts Component', () => {
props.onSearch();
} );
expect( useDebouncedCallback ).toHaveBeenCalled();
expect( mockUseDebounce.useDebouncedCallback ).toHaveBeenCalled();
expect( getProducts ).toHaveBeenCalledTimes( 1 );
} );
} );