More unit tests for checking correct definition of movie. Changed some test to match update functions in tmdb.
This commit is contained in:
30
seasoned_api/test/unit/tmdb/testConvertTmdbToMovie.js
Normal file
30
seasoned_api/test/unit/tmdb/testConvertTmdbToMovie.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const assert = require('assert');
|
||||
const convertTmdbToMovie = require('src/tmdb/convertTmdbToMovie');
|
||||
const bladeRunnerQuerySuccess = require('test/fixtures/blade_runner_2049-info-success-response.json')
|
||||
|
||||
describe('Convert tmdb movieInfo to movie', () => {
|
||||
beforeEach(() => this.bladeRunnerTmdbMovie = bladeRunnerQuerySuccess);
|
||||
|
||||
it('should translate the tmdb release date to movie year', () => {
|
||||
const bladeRunner = convertTmdbToMovie(this.bladeRunnerTmdbMovie);
|
||||
assert.strictEqual(bladeRunner.year, 2017);
|
||||
});
|
||||
|
||||
it('should translate the tmdb release date to instance of Date', () => {
|
||||
const bladeRunner = convertTmdbToMovie(this.bladeRunnerTmdbMovie);
|
||||
assert(bladeRunner.release_date instanceof Date);
|
||||
});
|
||||
|
||||
it('should translate the tmdb title to title', () => {
|
||||
const bladeRunner = convertTmdbToMovie(this.bladeRunnerTmdbMovie);
|
||||
assert.equal(bladeRunner.title, 'Blade Runner 2049');
|
||||
});
|
||||
|
||||
it('should translate the tmdb vote_average to rank', () => {
|
||||
const bladeRunner = convertTmdbToMovie(this.bladeRunnerTmdbMovie);
|
||||
assert.equal(bladeRunner.rank, 7.3);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
31
seasoned_api/test/unit/tmdb/testTmdb.disabled
Normal file
31
seasoned_api/test/unit/tmdb/testTmdb.disabled
Normal file
@@ -0,0 +1,31 @@
|
||||
const assert = require('assert');
|
||||
// const Movie = require('src/movie/movie');
|
||||
const TMDB = require('src/tmdb/tmdb');
|
||||
const Cache = require('src/tmdb/cache');
|
||||
const SqliteDatabase = require('src/database/sqliteDatabase');
|
||||
const tmdbMock = require('test/helpers/tmdbMock');
|
||||
|
||||
const emptyQuerySuccess = require('test/fixtures/empty-query-success-response.json');
|
||||
const interstellarQuerySuccess = require('test/fixtures/arrival-info-success-response.json');
|
||||
const popularMovieSuccessResponse = require('test/fixtures/popular-movies-success-response.json');
|
||||
|
||||
describe('TMDB', function test() {
|
||||
beforeEach(() => {
|
||||
this.mockMoviedb = tmdbMock();
|
||||
this.database = new SqliteDatabase(':memory:');
|
||||
return Promise.resolve()
|
||||
.then(() => this.database.setUp());
|
||||
});
|
||||
|
||||
describe('popular', () => {
|
||||
it('should return the "Blade Runner 2049" year in the collection of popular movies', () => {
|
||||
this.mockMoviedb.response = popularMovieSuccessResponse;
|
||||
const cache = new Cache(this.database);
|
||||
const tmdb = new TMDB(cache, 'bogus-api-key', this.mockMoviedb);
|
||||
return tmdb.popular()
|
||||
.then(movies =>
|
||||
assert.equal(movies[0].title, "Blade Runner 2049")
|
||||
);
|
||||
});
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user