-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinks.test.ts
109 lines (104 loc) · 3.09 KB
/
links.test.ts
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import {
isLink,
extractLinks,
} from '../src/utils/links';
describe('isLink util function', () => {
it('should return true', () => {
const result = isLink('http://www.foufos.gr');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('https://www.foufos.gr');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('http://foufos.gr');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('http://www.foufos.gr/kino');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('http://werer.gr');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('www.foufos.gr');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('www.mp3.com');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('www.t.co');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('http://t.co');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('http://www.t.co');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('https://www.t.co');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('www.aa.com');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('http://aa.com');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('http://www.aa.com');
expect(result).toBeTruthy();
});
it('should return true', () => {
const result = isLink('https://www.aa.com');
expect(result).toBeTruthy();
});
it('should return false', () => {
const result = isLink('www.foufos');
expect(result).toBeFalsy();
});
it('should return false', () => {
const result = isLink('www.foufos-.gr');
expect(result).toBeFalsy();
});
it('should return false', () => {
const result = isLink('www.-foufos.gr');
expect(result).toBeFalsy();
});
it('should return false', () => {
const result = isLink('foufos.gr');
expect(result).toBeFalsy();
});
it('should return false', () => {
const result = isLink('http://www.foufos');
expect(result).toBeFalsy();
});
it('should return false', () => {
const result = isLink('http://foufos');
expect(result).toBeFalsy();
});
it('should return false', () => {
const result = isLink('www.mp3#.com');
expect(result).toBeFalsy();
});
});
describe('extractLinks util function', () => {
it('should return an array of links', () => {
const result = extractLinks('hello, this is a link https://www.aa.com in a string');
expect(result?.[0]).toEqual('https://www.aa.com');
});
it('should return null if no links are found', () => {
const result = extractLinks('hello, there is no link in this string');
expect(result.length).toBe(0);
});
});