/
test.js
174 lines (162 loc) · 4.16 KB
/
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
var fs = require('fs');
var should = require('should');
var key = new String(fs.readFileSync(__dirname + '/APIKEY')).replace(/(\r\n|\n|\r)/gm,"");
var tmdb = require('../lib/tmdb').init(key);
describe("General methods", function() {
it("can get configuration info", function(done) {
tmdb.configuration(function(err,res) {
should.exist(res);
done();
});
});
});
describe("Person methods", function() {
it("can fetch info on a person", function(done){
tmdb.person.info(109, function(err,res) {
res.name.should.equal("Elijah Wood");
done();
});
});
it("can fetch a person's credits", function(done) {
tmdb.person.credits(109, function(err,res) {
res.id.should.equal(109);
done();
});
});
it("can fetch a person's images", function(done) {
tmdb.person.images(109, function(err,res) {
res.id.should.equal(109);
done();
})
});
});
describe("Search methods", function() {
it("can search for movies", function(done) {
tmdb.search.movie('transformers', function(err,res) {
res.page.should.equal(1);
done();
});
});
it("can hop to another page of a search", function(done) {
tmdb.search.movie('transformers', 4, function(err,res) {
res.page.should.equal(4);
done();
});
});
it("can search for persons", function(done) {
tmdb.search.person('mikael', function(err,res) {
res.page.should.equal(1);
done();
});
});
});
describe("Company methods", function() {
it("can get info on a company", function(done) {
tmdb.company.info(1, function(err,res) {
res.name.should.equal('Lucasfilm');
done();
});
});
it("can fetch what movies a company has produced", function(done) {
tmdb.company.movies(1, function(err,res) {
res.id.should.equal(1);
done();
});
});
});
describe("Collection methods", function() {
it("can get info on collections", function(done) {
tmdb.collection.info(10, function(err,res) {
res.name.should.equal('Star Wars Collection');
done();
});
});
});
describe("Movie methods", function() {
it("can get info on a movie", function(done) {
tmdb.movie.info(11, function(err,res) {
res.title.should.equal('Star Wars: Episode IV - A New Hope');
done();
});
});
it("can get data with an imdb-id", function(done) {
tmdb.movie.info('tt0076759', function(err,res) {
res.title.should.equal('Star Wars: Episode IV - A New Hope');
done();
});
});
it("can get alternative titles for a movie", function(done) {
tmdb.movie.alternativeTitles(11, function(err,res) {
res.id.should.equal(11);
done();
});
});
it("can detect invalid ids", function(done) {
tmdb.movie.info(1000000001, function(err,res) {
err.status_code.should.equal(6);
done();
});
});
it("can get the cast for a movie", function(done) {
tmdb.movie.casts(11, function(err,res) {
res.id.should.equal(11);
done();
});
});
it("can get images for a movie", function(done) {
tmdb.movie.images(11, function(err,res) {
res.id.should.equal(11);
done();
});
});
it("can get keywords for a movie", function(done) {
tmdb.movie.keywords(11, function(err,res) {
res.id.should.equal(11);
done();
});
});
it("can get release dates for a movie", function(done) {
tmdb.movie.releases(11, function(err,res) {
res.id.should.equal(11);
done();
});
});
it("can get trailers for a movie", function(done) {
tmdb.movie.trailers(11, function(err,res) {
res.id.should.equal(11);
done();
});
});
it("can get translations for a movie", function(done) {
tmdb.movie.translations(11, function(err,res) {
res.id.should.equal(11);
done();
});
});
});
describe("Misc methods", function() {
it("can get the latest added movie", function(done) {
tmdb.misc.latest(function(err,res) {
should.not.exist(err);
done();
});
});
it("can get the movies playing in theaters", function(done) {
tmdb.misc.nowPlaying(function(err,res) {
res.total_results.should.equal(100);
done();
});
});
it("can get popular movies", function(done) {
tmdb.misc.popular(function(err,res) {
res.page.should.equal(1);
done();
});
});
it("can get the top rated movies", function(done) {
tmdb.misc.topRated(function(err,res) {
res.page.should.equal(1);
done();
});
});
});