Skip to content

Commit f600144

Browse files
committed
Add missing test for validation mapper
1 parent 1542727 commit f600144

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/react-form-renderer/src/tests/validators/validators.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,31 @@ describe('New validators', () => {
7272
expect(validatorMapper(validators.MAX_LENGTH)({ threshold: 3, message: 'Too long!' })('1234')).toBe('Too long!');
7373
});
7474

75+
it('should pass max length of 3 characters long validation with typo (backwards compatibility)', () => {
76+
expect(validatorMapper(validators.MAX_LENGTH)({ treshold: 3 })('12')).toBeUndefined();
77+
});
78+
7579
it('should correctly pick threshold when using deprecated value', () => {
7680
expect(validatorMapper(validators.MIN_LENGTH)({ treshold: 3, message: 'Too short!' })('1')).toBe('Too short!');
7781
expect(validatorMapper(validators.MIN_LENGTH)({ threshold: 3, message: 'Too short!' })('1')).toBe('Too short!');
7882
expect(validatorMapper(validators.MIN_LENGTH)({ threshold: 5, treshold: 3, message: 'Too short!' })('12345')).toBeUndefined();
7983
});
84+
85+
it('should pass min items of 3 validation with typo', () => {
86+
expect(validatorMapper(validators.MIN_ITEMS_VALIDATOR)({ treshold: 3 })([ '1', '2', '3' ])).toBeUndefined();
87+
});
88+
89+
it('should pass min items of 3 validation', () => {
90+
expect(validatorMapper(validators.MIN_ITEMS_VALIDATOR)({ threshold: 3 })([ '1', '2', '3' ])).toBeUndefined();
91+
});
92+
93+
it('should pass min items of 3 validation', () => {
94+
expect(validatorMapper(validators.MIN_ITEMS_VALIDATOR)({ threshold: 3, message: 'Too few' })([ '1', '2' ])).toBe('Too few');
95+
});
96+
97+
it('should pass min items of 3 validation with more items', () => {
98+
expect(validatorMapper(validators.MIN_ITEMS_VALIDATOR)({ threshold: 3 })([ '1', '2', '3', '4' ])).toBeUndefined();
99+
});
80100
});
81101

82102
describe('pattern validator', () => {

0 commit comments

Comments
 (0)