From 606eb12abf40412fd6474fad6e5e8f52af8f92aa Mon Sep 17 00:00:00 2001 From: vashjs Date: Tue, 7 Nov 2023 20:07:52 +0000 Subject: [PATCH] Add fix to test --- src/QueryBuilder/QueryBuilder/helpers/query.js | 2 +- src/QueryBuilder/QueryBuilder/helpers/query.test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/QueryBuilder/QueryBuilder/helpers/query.js b/src/QueryBuilder/QueryBuilder/helpers/query.js index 4b1176fb..ef7af14e 100644 --- a/src/QueryBuilder/QueryBuilder/helpers/query.js +++ b/src/QueryBuilder/QueryBuilder/helpers/query.js @@ -178,7 +178,7 @@ export const mongoQueryToSource = async ({ intl, getParamsSource, }) => { - if (!fieldOptions?.length) return []; + if (!fieldOptions?.length || !Object.keys(initialValues).length) return []; const key = Object.keys(initialValues)[0]; const sharedArgs = { intl, booleanOptions, getParamsSource, fieldOptions }; diff --git a/src/QueryBuilder/QueryBuilder/helpers/query.test.js b/src/QueryBuilder/QueryBuilder/helpers/query.test.js index d6e23423..7cb7e587 100644 --- a/src/QueryBuilder/QueryBuilder/helpers/query.test.js +++ b/src/QueryBuilder/QueryBuilder/helpers/query.test.js @@ -10,6 +10,7 @@ describe('mongoQueryToSource()', () => { booleanOptions, fieldOptions, intl: { formatMessage: jest.fn() }, + getParamsSource: jest.fn(), }); expect(result).toEqual([]);