Skip to content

Commit d70ecbe

Browse files
committed
fix unit tests
1 parent e1ec666 commit d70ecbe

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/app/src/hooks/__tests__/useAutoCompleteOptions.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { renderHook } from '@testing-library/react';
44

55
import { LuceneLanguageFormatter } from '../../SearchInputV2';
66
import { useAutoCompleteOptions } from '../useAutoCompleteOptions';
7-
import { useAllFields, useGetKeyValues } from '../useMetadata';
7+
import { useAllFields, useGetKeyValues, useJsonColumns } from '../useMetadata';
88

99
if (!globalThis.structuredClone) {
1010
globalThis.structuredClone = (obj: any) => {
@@ -17,6 +17,7 @@ jest.mock('../useMetadata', () => ({
1717
...jest.requireActual('../useMetadata.tsx'),
1818
useAllFields: jest.fn(),
1919
useGetKeyValues: jest.fn(),
20+
useJsonColumns: jest.fn(),
2021
}));
2122

2223
const luceneFormatter = new LuceneLanguageFormatter();
@@ -60,6 +61,10 @@ describe('useAutoCompleteOptions', () => {
6061
(useGetKeyValues as jest.Mock).mockReturnValue({
6162
data: null,
6263
});
64+
65+
(useJsonColumns as jest.Mock).mockReturnValue({
66+
data: null,
67+
});
6368
});
6469

6570
it('should return field options with correct lucene formatting', () => {

packages/app/src/hooks/useAutoCompleteOptions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function useAutoCompleteOptions(
8282
}),
8383
);
8484
const searchKeys = useMemo(
85-
() => (searchField ? [mergePath(searchField.path, jsonColumns)] : []),
85+
() => (searchField ? [mergePath(searchField.path, jsonColumns ?? [])] : []),
8686
[searchField],
8787
);
8888

0 commit comments

Comments
 (0)