-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.js
79 lines (63 loc) 路 1.78 KB
/
index.test.js
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
const find = require('../src').find;
it('should be a function', () => {
expect(find).toEqual(jasmine.any(Function));
});
it('should inform that non-string is passed', () => {
expect(() => {
find(null)
}).toThrowError();
expect(() => {
find(undefined)
}).toThrowError();
expect(() => {
find([])
}).toThrowError();
expect(() => {
find({})
}).toThrowError();
});
it('should return empty collection when string not contain matched url', () => {
const input = find(
`
Wlaz艂 kotek na p艂otek
`
);
const output = [];
expect(input).toEqual(output);
});
it('should find one link', () => {
const input = find(
`
Text with link:
<https://docs.google.com/document/d/super-uniq-id/edit>
and nothing else!
Any other link should not be match. Especially that
http://example.com
`
);
const output = [
'https://docs.google.com/document/d/super-uniq-id/edit'
];
expect(input).toEqual(output);
});
it('should find more links', () => {
const input = find(
`
Text with link:
<https://docs.google.com/document/d/super-uniq-id/edit>
and nothing else!
Now, tool should match second link:
https://docs.google.com/document/d/super-uniq-id-2/edit
And next one!
https://docs.google.com/document/d/super-uniq-id-3/edit
But no more!
https://google.com/search?q=ciasteczko
`
);
const output = [
'https://docs.google.com/document/d/super-uniq-id/edit',
'https://docs.google.com/document/d/super-uniq-id-2/edit',
'https://docs.google.com/document/d/super-uniq-id-3/edit',
];
expect(input).toEqual(output);
});