Improve Filter chip empty state (#11704)
Cases: <img width="477" alt="image" src="https://github.com/user-attachments/assets/06da3efc-b878-499f-97de-570317caa9b7" /> <img width="477" alt="image" src="https://github.com/user-attachments/assets/40114c16-2810-489d-a60f-2579e2916691" /> <img width="477" alt="image" src="https://github.com/user-attachments/assets/fa80d7cf-7c2d-4c19-919e-2d4c78a9202b" />
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
|
||||
import { isFilterOperandExpectingValue } from '../isFilterOperandExpectingValue';
|
||||
|
||||
describe('isFilterOperandExpectingValue', () => {
|
||||
const testCases = [
|
||||
{ operand: ViewFilterOperand.Contains, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.DoesNotContain, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.GreaterThan, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.LessThan, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.Is, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IsNot, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IsRelative, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IsBefore, expectedResult: true },
|
||||
{ operand: ViewFilterOperand.IsAfter, expectedResult: true },
|
||||
|
||||
{ operand: ViewFilterOperand.IsNotNull, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsEmpty, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsNotEmpty, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsInPast, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsInFuture, expectedResult: false },
|
||||
{ operand: ViewFilterOperand.IsToday, expectedResult: false },
|
||||
];
|
||||
|
||||
testCases.forEach(({ operand, expectedResult }) => {
|
||||
it(`should return ${expectedResult} for ViewFilterOperand.${operand}`, () => {
|
||||
expect(isFilterOperandExpectingValue(operand)).toBe(expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,24 @@
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
|
||||
export const isFilterOperandExpectingValue = (operand: ViewFilterOperand) => {
|
||||
switch (operand) {
|
||||
case ViewFilterOperand.IsNotNull:
|
||||
case ViewFilterOperand.IsEmpty:
|
||||
case ViewFilterOperand.IsNotEmpty:
|
||||
case ViewFilterOperand.IsInPast:
|
||||
case ViewFilterOperand.IsInFuture:
|
||||
case ViewFilterOperand.IsToday:
|
||||
return false;
|
||||
case ViewFilterOperand.IsNot:
|
||||
case ViewFilterOperand.Contains:
|
||||
case ViewFilterOperand.DoesNotContain:
|
||||
case ViewFilterOperand.GreaterThan:
|
||||
case ViewFilterOperand.LessThan:
|
||||
case ViewFilterOperand.IsBefore:
|
||||
case ViewFilterOperand.IsAfter:
|
||||
case ViewFilterOperand.Is:
|
||||
case ViewFilterOperand.IsRelative:
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user