feat: Filter parameter: Improve loose type validation for booleans (#10702)
This commit is contained in:
@@ -19,6 +19,7 @@ const filterFactory = (data: DeepPartial<FilterValue> = {}): FilterValue =>
|
||||
combinator: 'and',
|
||||
conditions: [],
|
||||
options: {
|
||||
version: 1,
|
||||
leftValue: '',
|
||||
caseSensitive: false,
|
||||
typeValidation: 'strict',
|
||||
@@ -234,6 +235,48 @@ describe('FilterParameter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('options.version', () => {
|
||||
describe('version 1', () => {
|
||||
it('should parse "false" as true', () => {
|
||||
expect(
|
||||
executeFilter(
|
||||
filterFactory({
|
||||
conditions: [
|
||||
{
|
||||
id: '1',
|
||||
leftValue: 'false',
|
||||
rightValue: false,
|
||||
operator: { operation: 'equals', type: 'boolean' },
|
||||
},
|
||||
],
|
||||
options: { typeValidation: 'loose', version: 1 },
|
||||
}),
|
||||
),
|
||||
).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('version 2', () => {
|
||||
it('should parse "false" as false', () => {
|
||||
expect(
|
||||
executeFilter(
|
||||
filterFactory({
|
||||
conditions: [
|
||||
{
|
||||
id: '1',
|
||||
leftValue: 'false',
|
||||
rightValue: false,
|
||||
operator: { operation: 'equals', type: 'boolean' },
|
||||
},
|
||||
],
|
||||
options: { typeValidation: 'loose', version: 2 },
|
||||
}),
|
||||
),
|
||||
).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('operators', () => {
|
||||
describe('exists', () => {
|
||||
it.each([
|
||||
|
||||
Reference in New Issue
Block a user