-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirl-test.js
45 lines (39 loc) · 1.11 KB
/
irl-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
console.log('irl-test.js successfully loaded!');
const assert = require('assert');
const nock = require('nock');
const ytdl = require('..');
const videos = {
'Regular video': 'mgOS64BF2eU',
'Age restricted': 'Zc09khxyXfA',
'Embed domain restricted': 'B3eAMGXFw1o',
'No embed allowed': 'GFg8BP01F5Q',
Offensive: 'hCKDsjLt_qU',
'Live broadcast': '5qap5aO4i9A',
};
process.env.YTDL_NO_UPDATE = 'true';
describe('Try using ytdl-core without mocking', () => {
before(() => {
nock.cleanAll();
nock.enableNetConnect();
});
afterEach(() => {
ytdl.cache.sig.clear();
ytdl.cache.info.clear();
ytdl.cache.cookie.clear();
});
describe('Try starting a download', () => {
for (let [desc, videoID] of Object.entries(videos)) {
describe(desc, () => {
it('Request status code is 2xx', done => {
const stream = ytdl(videoID);
stream.on('error', done);
stream.once('response', res => {
stream.destroy();
assert.ok(res.statusCode >= 200 && res.statusCode < 300);
done();
});
});
});
}
});
});