Skip to content

Commit

Permalink
UIPQB-160: update query.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
UladzislauKutarkin committed Dec 3, 2024
1 parent 2fc7742 commit 5aa54c0
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/QueryBuilder/QueryBuilder/helpers/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,60 @@ describe('mongoQueryToSource()', () => {

expect(result).toEqual(initial);
});

it('should handle case when queried field is deleted', async () => {
const initialValuesUpdated = {
$and: [
{ user_first_name: { $eq: 'value' } },
{ delegate_languages: { $empty: true } },
],
};

const defaultField = fieldOptions[0];

const result = await mongoQueryToSource({
initialValues: initialValuesUpdated,
booleanOptions,
fieldOptions,
intl: { formatMessage: jest.fn() },
getParamsSource: jest.fn(),
});

expect(result).toEqual([
{
boolean: { options: booleanOptions, current: '$and' },
field: {
options: fieldOptions,
current: 'user_first_name',
dataType: 'stringType',
},
operator: {
dataType: 'stringType',
options: expect.any(Array),
current: '==',
},
value: { current: 'value', source: undefined, options: undefined },
},
{
boolean: { options: booleanOptions, current: '$and' },
field: {
options: fieldOptions,
current: 'delegate_languages',
dataType: defaultField?.dataType,
},
operator: {
dataType: defaultField?.dataType,
options: expect.any(Array),
current: '',
},
value: {
current: '',
source: defaultField?.source,
options: defaultField?.values,
},
},
]);
});
});

describe('isQueryValid', () => {
Expand Down

0 comments on commit 5aa54c0

Please sign in to comment.