Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { render, unmountComponentAtNode } from 'react-dom';
import { act, Simulate } from 'react-dom/test-utils';
import { queryByText, queryByRole } from '@testing-library/react';
import { first, last, nth, uniqueId } from 'lodash';
import { default as lodash, first, last, nth, uniqueId } from 'lodash';
/**
* WordPress dependencies
*/
Expand All @@ -16,6 +16,12 @@ import { UP, DOWN, ENTER } from '@wordpress/keycodes';
import LinkControl from '../';
import { fauxEntitySuggestions, fetchFauxEntitySuggestions } from './fixtures';

// Mock debounce() so that it runs instantly.
lodash.debounce = jest.fn( ( callback ) => {
callback.cancel = jest.fn();
return callback;
} );

const mockFetchSearchSuggestions = jest.fn();

jest.mock( '@wordpress/data/src/components/use-select', () => () => ( {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/url-input/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { throttle, isFunction } from 'lodash';
import { debounce, isFunction } from 'lodash';
import classnames from 'classnames';
import scrollIntoView from 'dom-scroll-into-view';

Expand Down Expand Up @@ -40,7 +40,7 @@ class URLInput extends Component {
this.bindSuggestionNode = this.bindSuggestionNode.bind( this );
this.autocompleteRef = props.autocompleteRef || createRef();
this.inputRef = createRef();
this.updateSuggestions = throttle(
this.updateSuggestions = debounce(
this.updateSuggestions.bind( this ),
200
);
Expand Down