|
| 1 | +// Import the function to test |
| 2 | +import { FeatureConfigFilterCondition } from 'src/modules/feature/model/features-config'; |
| 3 | +import { filterVersion } from './feature-version-filter.helper'; |
| 4 | + |
| 5 | +describe('filterVersion', () => { |
| 6 | + it('should return true for Eq condition when versions are equal', () => { |
| 7 | + expect(filterVersion(FeatureConfigFilterCondition.Eq, '1.0.0', '1.0.0')).toBe(true); |
| 8 | + }); |
| 9 | + |
| 10 | + it('should return false for Eq condition when versions are not equal', () => { |
| 11 | + expect(filterVersion(FeatureConfigFilterCondition.Eq, '1.0.1', '1.0.0')).toBe(false); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should return false for Neq condition when versions are equal', () => { |
| 15 | + expect(filterVersion(FeatureConfigFilterCondition.Neq, '1.0.0', '1.0.0')).toBe(false); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should return true for Neq condition when versions are not equal', () => { |
| 19 | + expect(filterVersion(FeatureConfigFilterCondition.Neq, '1.0.1', '1.0.0')).toBe(true); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should return true for Gt condition when first version is greater', () => { |
| 23 | + expect(filterVersion(FeatureConfigFilterCondition.Gt, '1.0.1', '1.0.0')).toBe(true); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should return false for Gt condition when first version is not greater', () => { |
| 27 | + expect(filterVersion(FeatureConfigFilterCondition.Gt, '1.0.0', '1.0.1')).toBe(false); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should return true for Gte condition when first version is greater', () => { |
| 31 | + expect(filterVersion(FeatureConfigFilterCondition.Gte, '1.0.1', '1.0.0')).toBe(true); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should return true for Gte condition when versions are equal', () => { |
| 35 | + expect(filterVersion(FeatureConfigFilterCondition.Gte, '1.0.0', '1.0.0')).toBe(true); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should return false for Gte condition when first version is less', () => { |
| 39 | + expect(filterVersion(FeatureConfigFilterCondition.Gte, '1.0.0', '1.0.1')).toBe(false); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should return true for Lt condition when first version is less', () => { |
| 43 | + expect(filterVersion(FeatureConfigFilterCondition.Lt, '1.0.0', '1.0.1')).toBe(true); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should return false for Lt condition when first version is not less', () => { |
| 47 | + expect(filterVersion(FeatureConfigFilterCondition.Lt, '1.0.1', '1.0.0')).toBe(false); |
| 48 | + }); |
| 49 | + |
| 50 | + it('should return true for Lte condition when first version is less', () => { |
| 51 | + expect(filterVersion(FeatureConfigFilterCondition.Lte, '1.0.0', '1.0.1')).toBe(true); |
| 52 | + }); |
| 53 | + |
| 54 | + it('should return true for Lte condition when versions are equal', () => { |
| 55 | + expect(filterVersion(FeatureConfigFilterCondition.Lte, '1.0.0', '1.0.0')).toBe(true); |
| 56 | + }); |
| 57 | + |
| 58 | + it('should return false for Lte condition when first version is greater', () => { |
| 59 | + expect(filterVersion(FeatureConfigFilterCondition.Lte, '1.0.1', '1.0.0')).toBe(false); |
| 60 | + }); |
| 61 | + |
| 62 | + it('should return false for unknown condition', () => { |
| 63 | + expect(filterVersion('UnknownCondition' as FeatureConfigFilterCondition, '1.0.0', '1.0.0')).toBe(false); |
| 64 | + }); |
| 65 | +}); |
0 commit comments