-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathvalidate.ts
More file actions
43 lines (34 loc) · 1.21 KB
/
Copy pathvalidate.ts
File metadata and controls
43 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { validMobileNo, validEmail, validSocial } from "../src/index";
describe("validMobileNo", () => {
test("Valid mobile number with + sign and 15 digits", () => {
expect(validMobileNo("+234706469321234")).toBe(true);
});
test("Invalid mobile number without + sign", () => {
expect(validMobileNo("234706469321234")).toBe(false);
});
test("Invalid mobile number with more than 15 digits", () => {
expect(validMobileNo("+23470646932123456")).toBe(false);
});
});
describe("validEmail", () => {
test("Valid email address", () => {
expect(validEmail("example@mail.com")).toBe(true);
});
test('Invalid email address without "@" symbol', () => {
expect(validEmail("examplemail.com")).toBe(false);
});
test("Invalid email address without domain", () => {
expect(validEmail("example@mail")).toBe(false);
});
});
describe("validSocial", () => {
test("Valid Facebook URL", () => {
expect(validSocial("https://www.facebook.com/example")).toBe(true);
});
test("Valid Twitter URL", () => {
expect(validSocial("https://www.twitter.com/example")).toBe(true);
});
test("Invalid URL", () => {
expect(validSocial("https://www.invalid.com/example")).toBe(false);
});
});