Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 5677593

Browse files
committed
added tests for isEmail and validationRules
1 parent 08d1342 commit 5677593

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/validationRules.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,34 @@ describe('Validation Rules', () => {
7575
expect(valid).toBe(false);
7676
});
7777
});
78+
79+
describe('isEmail', () => {
80+
it('should validate an correct email successfully', () => {
81+
const valid = rules.isEmail(null, 'test@gmail.com');
82+
expect(valid).toBe(true);
83+
});
84+
it('should invalidate an incorrect email', () => {
85+
let valid = rules.isEmail(null, 'abc');
86+
expect(valid).toBe(false);
87+
valid = rules.isEmail(null, null);
88+
expect(valid).toBe(false);
89+
valid = rules.isEmail(null, 'abc@abc');
90+
expect(valid).toBe(false);
91+
valid = rules.isEmail(null, 'abc@abc.');
92+
expect(valid).toBe(false);
93+
});
94+
});
95+
96+
describe('minLength', () => {
97+
it('should validate the string successfully', () => {
98+
let valid = rules.minLength(null, 'abcdef', 6);
99+
expect(valid).toBe(true);
100+
valid = rules.minLength(null, 'abcdef', 4);
101+
expect(valid).toBe(true);
102+
});
103+
it('should invalidate the string', () => {
104+
let valid = rules.minLength(null, 'abcde', 6);
105+
expect(valid).toBe(false);
106+
});
107+
})
78108
});

0 commit comments

Comments
 (0)