Skip to content

Commit

Permalink
fix jest
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Feb 16, 2021
1 parent 5ecdcbd commit 3ecb615
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('FieldSuggestions', () => {

beforeEach(() => {
const uiSettings = { get: (key: string) => shouldSuggestValues } as IUiSettingsClient;
http = { fetch: jest.fn() };
http = { fetch: jest.fn().mockResolvedValue([]) };

getValueSuggestions = setupValueSuggestionProvider({ http, uiSettings } as CoreSetup, {
timefilter: ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const setupValueSuggestionProvider = (
}: { timefilter: TimefilterSetup; usageCollector?: AutocompleteUsageCollector }
): ValueSuggestionsGetFn => {
function resolver(title: string, field: IFieldType, query: string, filters: any[]) {
usageCollector?.trackCall();
// Only cache results for a minute
const ttl = Math.floor(Date.now() / 1000 / 60);
return [ttl, query, title, field.name, JSON.stringify(filters)].join('|');
Expand Down Expand Up @@ -98,6 +97,7 @@ export const setupValueSuggestionProvider = (
const filterQuery = timeFilter ? buildQueryFromFilters([timeFilter], indexPattern).filter : [];
const filters = [...(boolFilter ? boolFilter : []), ...filterQuery];
try {
usageCollector?.trackCall();
return await requestSuggestions(title, field, query, filters, signal);
} catch (e) {
if (!signal?.aborted) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('SuggestionsComponent', () => {

component.find(SuggestionComponent).at(1).simulate('click');
expect(mockCallback).toHaveBeenCalledTimes(1);
expect(mockCallback).toHaveBeenCalledWith(mockSuggestions[1]);
expect(mockCallback).toHaveBeenCalledWith(mockSuggestions[1], 1);
});

it('Should call onMouseEnter with the index of the suggestion that was entered', () => {
Expand Down

0 comments on commit 3ecb615

Please sign in to comment.