-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main-tests.js
94 lines (70 loc) · 2 KB
/
main-tests.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const { throws, deepEqual } = require('assert');
const mod = require('./main.js');
describe('_OLSKWashGlobalKeys', function test__OLSKWashGlobalKeys() {
it('returns array', function () {
deepEqual(mod._OLSKWashGlobalKeys(), [
'fbclid',
'gclid',
'twclid',
'igshid',
'igsh',
'utm_source',
'utm_medium',
'utm_campaign',
]);
});
});
describe('_OLSKWashDomainKeys', function test__OLSKWashDomainKeys() {
it('returns array', function () {
deepEqual(mod._OLSKWashDomainKeys(), {
'spotify.com': [
'si',
'_branch_referrer',
'_branch_match_id',
'$full_url',
],
'twitter.com': [
's',
],
'youtube.com': [
'pp',
],
});
});
});
describe('OLSKWash', function test_OLSKWash() {
it('throws if not string', function () {
throws(function () {
mod.OLSKWash(null);
}, /OLSKErrorInputNotValid/);
});
it('returns inputData', function () {
const item = uLink();
deepEqual(mod.OLSKWash(item), item);
});
it('preserves hash', function () {
const item = uLink() + '#alfa' + Math.random().toString();
deepEqual(mod.OLSKWash(item), item);
});
context('_OLSKWashGlobalKeys', function () {
mod._OLSKWashGlobalKeys().forEach(function (e) {
it('scrubs ' + e, function () {
const flag = uRandomElement(true, false)
const item = uLink() + (flag ? '?alfa=bravo' : '');
deepEqual(mod.OLSKWash([item, flag ? '&' : '?', e + '=', Math.random().toString()].join('')), item);
});
});
});
context('_OLSKWashDomainKeys', function () {
Object.entries(mod._OLSKWashDomainKeys()).forEach(function ([key, params]) {
params.forEach(function (value) {
it('scrubs ' + value, function () {
const flag = uRandomElement(true, false)
const link = `https://${ flag ? Math.random().toString() + key : 'example.com' }/playlist/1wkrgUQ6LcTCtpdCvtKjaj`;
const item = '?' + value + '=' + Math.random().toString();
deepEqual(mod.OLSKWash([link, item].join('')), link + (flag ? '' : item));
});
});
});
});
});