diff --git a/plugins/woocommerce-blocks/assets/js/hocs/test/with-searched-products.js b/plugins/woocommerce-blocks/assets/js/hocs/test/with-searched-products.js index 4fd61c1d9d0..4c814824ee7 100644 --- a/plugins/woocommerce-blocks/assets/js/hocs/test/with-searched-products.js +++ b/plugins/woocommerce-blocks/assets/js/hocs/test/with-searched-products.js @@ -6,13 +6,24 @@ */ import TestRenderer, { act } from 'react-test-renderer'; import * as mockUtils from '@woocommerce/editor-components/utils'; -import * as mockUseDebounce from 'use-debounce'; +import { useDebouncedCallback } 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: { @@ -28,15 +39,10 @@ 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( () => { - mockUseDebounce.useDebouncedCallback.mockClear(); + useDebouncedCallback.mockClear(); mockUtils.getProducts.mockClear(); } ); const TestComponent = withSearchedProducts( @@ -77,7 +83,7 @@ describe( 'withSearchedProducts Component', () => { props.onSearch(); } ); - expect( mockUseDebounce.useDebouncedCallback ).toHaveBeenCalled(); + expect( useDebouncedCallback ).toHaveBeenCalled(); expect( getProducts ).toHaveBeenCalledTimes( 1 ); } ); } ); diff --git a/plugins/woocommerce-blocks/package-lock.json b/plugins/woocommerce-blocks/package-lock.json index d40f85c2f12..167cb717320 100644 --- a/plugins/woocommerce-blocks/package-lock.json +++ b/plugins/woocommerce-blocks/package-lock.json @@ -46,7 +46,7 @@ "reakit": "1.3.11", "request": "2.88.2", "trim-html": "0.1.9", - "use-debounce": "7.0.1", + "use-debounce": "9.0.4", "wordpress-components": "npm:@wordpress/components@14.2.0" }, "devDependencies": { @@ -52207,9 +52207,9 @@ } }, "node_modules/use-debounce": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/use-debounce/-/use-debounce-7.0.1.tgz", - "integrity": "sha512-fOrzIw2wstbAJuv8PC9Vg4XgwyTLEOdq4y/Z3IhVl8DAE4svRcgyEUvrEXu+BMNgMoc3YND6qLT61kkgEKXh7Q==", + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/use-debounce/-/use-debounce-9.0.4.tgz", + "integrity": "sha512-6X8H/mikbrt0XE8e+JXRtZ8yYVvKkdYRfmIhWZYsP8rcNs9hk3APV8Ua2mFkKRLcJKVdnX2/Vwrmg2GWKUQEaQ==", "engines": { "node": ">= 10.0.0" }, @@ -95002,9 +95002,9 @@ "dev": true }, "use-debounce": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/use-debounce/-/use-debounce-7.0.1.tgz", - "integrity": "sha512-fOrzIw2wstbAJuv8PC9Vg4XgwyTLEOdq4y/Z3IhVl8DAE4svRcgyEUvrEXu+BMNgMoc3YND6qLT61kkgEKXh7Q==", + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/use-debounce/-/use-debounce-9.0.4.tgz", + "integrity": "sha512-6X8H/mikbrt0XE8e+JXRtZ8yYVvKkdYRfmIhWZYsP8rcNs9hk3APV8Ua2mFkKRLcJKVdnX2/Vwrmg2GWKUQEaQ==", "requires": {} }, "use-isomorphic-layout-effect": { diff --git a/plugins/woocommerce-blocks/package.json b/plugins/woocommerce-blocks/package.json index 0e5cbfebf3b..af013dd83ea 100644 --- a/plugins/woocommerce-blocks/package.json +++ b/plugins/woocommerce-blocks/package.json @@ -277,7 +277,7 @@ "reakit": "1.3.11", "request": "2.88.2", "trim-html": "0.1.9", - "use-debounce": "7.0.1", + "use-debounce": "9.0.4", "wordpress-components": "npm:@wordpress/components@14.2.0" }, "peerDependencies": {