youtube.js
2.64 KB
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
var config = require('./config.conf');
var YouTube = require('../lib/youtube');
var should = require('should');
describe('Youtube', function() {
this.timeout(10000);
it('Require key', function(done) {
var youTube = new YouTube();
youTube.search(config.query, 1, function(err, response) {
err.should.have.property('error', {message: 'Please set a key using setKey method. Get an key in https://console.developers.google.com'});
done();
});
});
it('getById', function(done) {
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.getById(config.id, function(err, response) {
response.should.have.property('kind', 'youtube#videoListResponse');
done();
});
});
it('getChannelById', function(done) {
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.getById(config.channelId, function(err, response) {
response.should.have.property('kind', 'youtube#videoListResponse');
done();
});
});
it('search', function(done) {
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.search(config.query, 1, function(err, response) {
response.should.have.property('kind', 'youtube#searchListResponse');
done();
});
});
it('related', function(done) {
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.related(config.id, 1, function(err, response) {
response.should.have.property('kind', 'youtube#searchListResponse');
done();
});
});
it('getPlayListsById', function(done) {
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.getPlayListsById(config.playlistId, function(err, response) {
response.should.have.property('kind', 'youtube#playlistListResponse');
done();
});
});
it('getPlayListsItemsById', function(done) {
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.getPlayListsItemsById(config.playlistId, function(err, response) {
response.should.have.property('kind', 'youtube#playlistItemListResponse');
done();
});
});
it('getMostPopular', function(done) {
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.getMostPopular(2, function(err, response) {
response.should.have.property('kind', 'youtube#videoListResponse');
done();
});
});
it('getMostPopularByCategory', function(done) {
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.getMostPopularByCategory(2, 1, function(err, response) {
response.should.have.property('kind', 'youtube#videoListResponse');
done();
});
});
});