mirror of
https://github.com/KevinMidboe/moviedb.git
synced 2025-10-29 17:50:25 +00:00
Merge pull request #31 from danieldmo/daniel
adding methods 'tvAiringToday' and 'tvOnTheAir' + unit tests
This commit is contained in:
4
Makefile
Normal file
4
Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
test:
|
||||
./node_modules/.bin/mocha --reporter spec
|
||||
|
||||
.PHONY: test
|
||||
18
Readme.md
18
Readme.md
@@ -67,7 +67,23 @@ All themoviedb.org API v3 methods included (I have plans to change this method n
|
||||
| accountFavoriteMovies | account/:id/favorite_movies |
|
||||
| accoutRatedMovies | account/:id/rated_movies |
|
||||
| accountAddFavorite | account/:id/favorite |
|
||||
|
||||
| tvInfo | tv/:id |
|
||||
| tvCredits | tv/:id/credits |
|
||||
| tvExternalIds | tv/:id/external_ids |
|
||||
| tvImages | tv/:id/images |
|
||||
| tvVideos | tv/:id/videos |
|
||||
| tvSimilar | tv/:id/similar |
|
||||
| tvTranslations | tv/:id/translations |
|
||||
| tvSeasonInfo | tv/:id/season/:season_number |
|
||||
| tvSeasonCredits | tv/:id/season/:season_number/credits |
|
||||
| tvSeasonExternalIds | tv/:id/season/:season_number/external_ids |
|
||||
| tvSeasonImages | tv/:id/season/:season_number/images |
|
||||
| tvEpisodeInfo | tv/:id/season/:season_number/episode/:episode_number |
|
||||
| tvEpisodeCredits | tv/:id/season/:season_number/episode/:episode_number/credits |
|
||||
| tvEpisodeExternalIds | tv/:id/season/:season_number/episode/:episode_number/external_ids |
|
||||
| tvEpisodeImages | tv/:id/season/:season_number/episode/:episode_number/images |
|
||||
| tvOnTheAir | tv/on_the_air |
|
||||
| tvAiringToday | tv/airing_today |
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
, "EpisodeCredits" : { "resource": "tv/:id/season/:season_number/episode/:episode_number/credits", "method": "get" }
|
||||
, "EpisodeExternalIds" : { "resource": "tv/:id/season/:season_number/episode/:episode_number/external_ids", "method": "get" }
|
||||
, "EpisodeImages" : { "resource": "tv/:id/season/:season_number/episode/:episode_number/images", "method": "get" }
|
||||
, "OnTheAir" : { "resource": "tv/on_the_air", "method": "get" }
|
||||
, "AiringToday" : { "resource": "tv/airing_today", "method": "get" }
|
||||
}
|
||||
, "person" : {
|
||||
"Info" : { "resource": "person/:id", "method": "get" }
|
||||
|
||||
16
package.json
16
package.json
@@ -2,9 +2,12 @@
|
||||
"name": "moviedb",
|
||||
"description": "Library for interacting with themoviedb.com API",
|
||||
"version": "0.2.2",
|
||||
"scripts": {
|
||||
"test": "clear; make test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/impronunciable/moviedb.git"
|
||||
"url": "git+https://github.com/impronunciable/moviedb.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
@@ -12,11 +15,6 @@
|
||||
"api",
|
||||
"tmdb"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/impronunciable/moviedb.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/impronunciable/moviedb/issues"
|
||||
},
|
||||
@@ -27,6 +25,12 @@
|
||||
"main": "index.js",
|
||||
"author": "Dan Zajdband <dan.zajdband@gmail.com>",
|
||||
"dependencies": {
|
||||
"chai": "^3.4.1",
|
||||
"colors": "^1.1.2",
|
||||
"superagent": "0.21.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^3.4.1",
|
||||
"mocha": "^2.3.4"
|
||||
}
|
||||
}
|
||||
|
||||
64
test/index.js
Normal file
64
test/index.js
Normal file
@@ -0,0 +1,64 @@
|
||||
var should = require('chai').should();
|
||||
var assert = require('chai').assert;
|
||||
var colors = require('colors');
|
||||
var apiKey = process.env.npm_config_key;
|
||||
var api;
|
||||
|
||||
/**
|
||||
* checks for missing API key
|
||||
*
|
||||
* the proper way to run the test
|
||||
*
|
||||
* npm test --key='{your api key}'
|
||||
*
|
||||
* @param {[type]} !apiKey || apiKey.length [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
if (!apiKey || apiKey.length === 0) {
|
||||
console.log('You have not provided the API key'.red);
|
||||
console.log(' Running tests:'.cyan);
|
||||
console.log(' npm test --key="{your api key}"'.cyan);
|
||||
throw new Error('Missing API key, please `run npm test --key="{your api key}"`');
|
||||
}
|
||||
|
||||
api = require('../index.js')(apiKey);
|
||||
|
||||
describe('moviedb', function() {
|
||||
|
||||
this.timeout(10000);
|
||||
|
||||
// basic movie search
|
||||
it('should search for Zoolander', function(done) {
|
||||
api.searchMovie({query: 'Zoolander' }, function(err, res){
|
||||
if (err) done(err);
|
||||
// console.log(res);
|
||||
res.should.be.an('object');
|
||||
res.should.have.property('results');
|
||||
res.results.should.be.an('array');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get the tv shows airing today', function(done) {
|
||||
api.tvAiringToday(function(err, res) {
|
||||
if (err) done(err);
|
||||
// console.log(data);
|
||||
res.should.be.an('object');
|
||||
res.should.have.property('results');
|
||||
res.results.should.be.an('array');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get the tv shows OnTheAir', function(done) {
|
||||
api.tvOnTheAir(function(err, res) {
|
||||
if (err) done(err);
|
||||
// console.log(data);
|
||||
res.should.be.an('object');
|
||||
res.should.have.property('results');
|
||||
res.results.should.be.an('array');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user