-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathtest-proxies.js
89 lines (77 loc) · 1.92 KB
/
test-proxies.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
const { expect } = require('chai');
const proxyLoader = require('simple-proxies/lib/proxyfileloader');
const serp = require('../index.js');
describe('Test Simple Search with proxy', async () => {
let proxyList = null;
before(async () => {
try {
console.log('Loading proxies ...');
const config = proxyLoader.config()
.setProxyFile('./proxies.txt')
.setCheckProxies(true)
.setRemoveInvalidProxies(true);
proxyList = await proxyLoader.loadProxyFile(config);
console.log(`Proxies loaded : ${ proxyList.getNumberOfProxies() }`);
} catch (e) {
console.log(e);
}
});
it('Should return 0 for number of results of a non indexed site', async () => {
// this.timeout(60000);
const options = {
host: 'google.be',
numberOfResults: true,
qs: {
q: 'site:tootofffd.be'
},
proxyList
};
try {
const nbr = await serp.search(options);
expect(nbr).equals(0);
} catch (e) {
expect(e).be.null;
}
});
it('Should return 12 links with a specific host and extra parameters', async () => {
// this.timeout(20000);
const options = {
host: 'google.be',
num: 12,
qs: {
q: 'test',
pws: 0,
lr: 'lang_fr',
cr: 'BE'
},
proxyList
};
try {
const links = await serp.search(options);
expect(links).to.have.lengthOf(12);
} catch (e) {
expect(e).be.null;
}
});
it('Should return 15 links with delay between each requests', async () => {
// this.timeout(60000);
const options = {
host: 'google.be',
num: 15,
delay: 5000,
qs: {
q: 'test',
pws: 0,
lr: 'lang_fr',
cr: 'BE'
},
proxyList
};
try {
const links = await serp.search(options);
expect(links).to.have.lengthOf(15);
} catch (e) {
expect(e).be.null;
}
});
});