Comparing version 0.3.3 to 0.4.0
{ | ||
"name": "imdbtr", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "IMDB on terminal", | ||
@@ -25,6 +25,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"chalk": "^1.1.1", | ||
"figures": "^1.4.0", | ||
"got": "^6.1.1", | ||
"minimist": "^1.2.0" | ||
"chalk": "^1.1.3", | ||
"figures": "^1.7.0", | ||
"got": "^6.3.0", | ||
"minimist": "^1.2.0", | ||
"ora": "^0.2.3" | ||
}, | ||
@@ -37,4 +38,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"ava": "^0.11.0", | ||
"xo": "^0.12.1" | ||
"ava": "^0.15.2", | ||
"sinon": "^1.17.4", | ||
"xo": "^0.16.0" | ||
}, | ||
@@ -41,0 +43,0 @@ "bin": { |
'use strict'; | ||
const got = require('got'); | ||
const helpers = require('./helpers'); | ||
const got = require('got'); | ||
const provider = 'http://www.omdbapi.com/?'; | ||
@@ -22,4 +23,4 @@ const headers = { | ||
}) | ||
.catch(error => { | ||
return error.body; | ||
.catch(err => { | ||
return err.body; | ||
}); | ||
@@ -26,0 +27,0 @@ |
'use strict'; | ||
const normalizeName = name => { | ||
const nameList = name.split(' ', 2); | ||
const nameList = name.split(' '); | ||
@@ -6,0 +6,0 @@ let normalizedList = nameList.map(currName => { |
'use strict'; | ||
const api = require('./api.js'); | ||
const chalk = require('chalk'); | ||
const figures = require('figures'); | ||
const ora = require('ora'); | ||
const api = require('./api.js'); | ||
@@ -14,3 +15,5 @@ const imdbtr = name => { | ||
const spinner = ora(`Searching for ${chalk.yellow(name)}`).start(); | ||
return movie.then(result => { | ||
spinner.stop(); | ||
if (!result) { | ||
@@ -33,2 +36,6 @@ return console.log(chalk.yellow.bold('Movie not found on IMDB :(')); | ||
console.log(movieRes); | ||
}).catch(err => { | ||
spinner.stop(); | ||
console.error(chalk.red.bold('Something went wrong :(')); | ||
console.error(err); | ||
}); | ||
@@ -35,0 +42,0 @@ }; |
'use strict'; | ||
const test = require('ava'); | ||
const api = require('../src/helpers.js'); | ||
const helpers = require('../src/helpers.js'); | ||
test(`should return the name of movie when it's valid title`, async t => { | ||
const result = await api('The Godfather'); | ||
test(`should return a compound name with plus char`, t => { | ||
t.is(helpers.normalizeName('The Walking Dead'), 'The+Walking+Dead'); | ||
}); | ||
t.is(result.Title, 'The Godfather'); | ||
t.is(result.Year, '1972'); | ||
test(`should return a name with accent encoded`, t => { | ||
t.is(helpers.normalizeName('Garoto Cósmico'), 'Garoto+C%C3%B3smico'); | ||
}); | ||
test(`should return a name with one word`, t => { | ||
t.is(helpers.normalizeName('Deadpool'), 'Deadpool'); | ||
}); |
Sorry, the diff of this file is not supported yet
22985
13
139
5
3
+ Addedora@^0.2.3
+ Addedcli-cursor@1.0.2(transitive)
+ Addedcli-spinners@0.1.2(transitive)
+ Addedexit-hook@1.1.1(transitive)
+ Addedonetime@1.1.0(transitive)
+ Addedora@0.2.3(transitive)
+ Addedrestore-cursor@1.0.1(transitive)
Updatedchalk@^1.1.3
Updatedfigures@^1.7.0
Updatedgot@^6.3.0