-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1186 from securityscorecard/ajkl2533@UXD-1661
fix(Filters): make operator parsing case insensitive
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { getOperatorOptions } from './FilterRow'; | ||
|
||
describe('getOperatorOptions', () => { | ||
it('should return the correct operator option when a matching value exists', () => { | ||
const operatorValue = 'or'; | ||
const operatorOptions = [ | ||
{ value: 'or', label: 'or' }, | ||
{ value: 'and', label: 'and' }, | ||
]; | ||
const result = getOperatorOptions(operatorValue, operatorOptions); | ||
expect(result).toEqual({ value: 'or', label: 'or' }); | ||
}); | ||
|
||
it('should return the correct operator option when a matching value exists (CASE INSENSITIVE)', () => { | ||
const operatorValue = 'OR'; | ||
const operatorOptions = [ | ||
{ value: 'or', label: 'or' }, | ||
{ value: 'and', label: 'and' }, | ||
]; | ||
const result = getOperatorOptions(operatorValue, operatorOptions); | ||
expect(result).toEqual({ value: 'or', label: 'or' }); | ||
}); | ||
|
||
it('should return undefined when no matching operator value is found', () => { | ||
const operatorValue = 'greaterThan'; | ||
const operatorOptions = [ | ||
{ value: 'or', label: 'or' }, | ||
{ value: 'and', label: 'and' }, | ||
]; | ||
const result = getOperatorOptions(operatorValue, operatorOptions); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
it('should return undefined when operatorOptions array is empty', () => { | ||
const operatorValue = 'or'; | ||
const operatorOptions = []; | ||
const result = getOperatorOptions(operatorValue, operatorOptions); | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); |