1 | var should = require('chai').should();
|
2 | var assert = require('chai').assert;
|
3 | var colors = require('colors');
|
4 | var apiKey = process.env.MOVIEDB_API_KEY || process.env.npm_config_key;
|
5 | var api;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | if (!apiKey || apiKey.length === 0) {
|
18 | console.log('You have not provided the API key'.red);
|
19 | console.log(' Running tests:'.cyan);
|
20 | console.log(' npm test --key="{your api key}"'.cyan);
|
21 | throw new Error('Missing API key, please `run npm test --key="{your api key}"`');
|
22 | }
|
23 |
|
24 | api = require('../index.js')(apiKey);
|
25 |
|
26 | describe('moviedb', function() {
|
27 |
|
28 | this.timeout(10000);
|
29 |
|
30 |
|
31 | it('should search for Zoolander', function(done) {
|
32 | api.searchMovie({query: 'Zoolander' }, function(err, res){
|
33 | if (err) done(err);
|
34 |
|
35 | res.should.be.an('object');
|
36 | res.should.have.property('results');
|
37 | res.results.should.be.an('array');
|
38 | done();
|
39 | });
|
40 | });
|
41 |
|
42 | it('should get the tv shows airing today', function(done) {
|
43 | api.tvAiringToday(function(err, res) {
|
44 | if (err) done(err);
|
45 |
|
46 | res.should.be.an('object');
|
47 | res.should.have.property('results');
|
48 | res.results.should.be.an('array');
|
49 | done();
|
50 | });
|
51 | });
|
52 |
|
53 | it('should get the tv shows OnTheAir', function(done) {
|
54 | api.tvOnTheAir(function(err, res) {
|
55 | if (err) done(err);
|
56 |
|
57 | res.should.be.an('object');
|
58 | res.should.have.property('results');
|
59 | res.results.should.be.an('array');
|
60 | done();
|
61 | });
|
62 | });
|
63 |
|
64 | it ('should get the movie release dates', function(done) {
|
65 | api.movieReleaseDates({id: 209112}, function(err, res) {
|
66 | if (err) done(err);
|
67 | res.should.be.an('object');
|
68 | res.should.have.property('results');
|
69 | res.results.should.be.an('array');
|
70 | assert.equal(res.id, 209112);
|
71 | done();
|
72 | });
|
73 | });
|
74 |
|
75 | });
|