New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imdb-api

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imdb-api - npm Package Compare versions

Comparing version 2.2.2 to 3.0.0

21

CHANGELOG.md

@@ -0,12 +1,25 @@

# Version 2.2.2 -> 3.0.0
This is a breaking change
* Added support for passing in options to all `get` functions
* Require an apiKey option for authentication to omdb
```js
imdb.get('The Toxic Avenger', {apiKey: 'foo'}).then(function(data) { console.log(data); });
```
To see more about getting a key, see [here](https://www.patreon.com/posts/api-is-going-10743518)
# Version 2.2.1 -> 2.2.2
Fixed broken date parsing ([PR](https://github.com/worr/node-imdb-api/pull/41))
* Fixed broken date parsing ([PR](https://github.com/worr/node-imdb-api/pull/41))
# Version 2.2.0 -> 2.2.1
Bug fixes
* Bug fixes
# Version 2.1.0 -> 2.2.0
Added promise API
* Added promise API

@@ -21,3 +34,3 @@ ## Promises

Adds the ability to filter by year
* Adds the ability to filter by year

@@ -24,0 +37,0 @@ ## Filtering by year

26

lib/imdb.js

@@ -83,3 +83,3 @@ "use strict";

__extends(TVShow, _super);
function TVShow(object) {
function TVShow(object, apiKey) {
var _this = _super.call(this, object) || this;

@@ -91,2 +91,3 @@ _this._episodes = [];

_this.totalseasons = parseInt(_this["totalseasons"]);
_this._apikey = apiKey;
return _this;

@@ -101,3 +102,3 @@ }

for (var i = 1; i <= tvShow.totalseasons; i++) {
funcs.push(rp({ "qs": { "i": tvShow.imdbid, "r": "json", "Season": i }, "json": true, "url": omdbapi }));
funcs.push(rp({ "qs": { "apikey": tvShow._apikey, "i": tvShow.imdbid, "r": "json", "Season": i }, "json": true, "url": omdbapi }));
}

@@ -151,4 +152,13 @@ var prom = Promise.all(funcs)

function getReq(req, cb) {
if (req.opts === undefined || !req.opts.hasOwnProperty("apiKey")) {
var err = new ImdbError("Missing api key in opts", req);
if (cb) {
return cb(err, undefined);
}
else {
return Promise.reject(err);
}
}
var responseData = "";
var qs = { plot: "full", r: "json", y: req.year };
var qs = { apikey: req.opts.apiKey, plot: "full", r: "json", y: req.year };
if (req.name) {

@@ -176,3 +186,3 @@ qs["t"] = req.name;

else if (interfaces_1.isTvshow(data)) {
ret = new TVShow(data);
ret = new TVShow(data, req.opts.apiKey);
}

@@ -207,10 +217,10 @@ else if (interfaces_1.isEpisode(data)) {

exports.getReq = getReq;
function get(name, cb) {
return getReq({ id: undefined, name: name }, cb);
function get(name, opts, cb) {
return getReq({ id: undefined, opts: opts, name: name }, cb);
}
exports.get = get;
function getById(imdbid, cb) {
return getReq({ id: imdbid, name: undefined }, cb);
function getById(imdbid, opts, cb) {
return getReq({ id: imdbid, opts: opts, name: undefined }, cb);
}
exports.getById = getById;
//# sourceMappingURL=imdb.js.map

@@ -5,3 +5,3 @@ {

"description": "Queries unofficial imdb APIs to get movie and television information from imdb",
"version": "2.2.2",
"version": "3.0.0",
"main": "lib/imdb.js",

@@ -8,0 +8,0 @@ "homepage": "https://github.com/worr/node-imdb-api",

@@ -14,3 +14,3 @@ # node-imdb-api

# Upgrading from 1.3.3?
# Upgrading from 1.x or 2.x?

@@ -29,3 +29,3 @@ Many things have changed. Read the [changelog](CHANGELOG.md)

imdb.getReq({ name: 'The Toxic Avenger' }, (err, things) => {
imdb.getReq({ apiKey: 'foo', name: 'The Toxic Avenger' }, (err, things) => {
movie = things;

@@ -35,5 +35,5 @@ });

// Promises!
imdb.get('The Toxic Avenger').then(console.log);
imdb.getById('tt0090190').then(console.log);
imdb.getReq({ name: 'The Toxic Avenger' }).then(console.log);
imdb.get('The Toxic Avenger', {apiKey: 'foo'}).then(console.log);
imdb.getById('tt0090190', {apiKey: 'foo'}).then(console.log);
imdb.getReq({ name: 'The Toxic Avenger', opts: {apiKey: 'foo'} }).then(console.log);
```

@@ -72,3 +72,3 @@ DATA

let movie;
imdb.getReq({ id: 'tt0090190' }, (err, things) => {
imdb.getReq({ id: 'tt0090190', opts: {apiKey: 'foo'} }, (err, things) => {
movie = things;

@@ -109,7 +109,7 @@ });

```js
imdb.get('How I Met Your Mother').then(things => {
imdb.get('How I Met Your Mother', {apiKey: 'foo'}).then(things => {
things.episodes().then(console.log);
});
imdb.get('How I Met Your Mother', (err, things) => {
imdb.get('How I Met Your Mother', {apiKey: 'foo'}, (err, things) => {
things.episodes((err, moreThings) => console.log(moreThings));

@@ -158,2 +158,10 @@ });

## I see an API key in your examples? Is it required? How do I get one?
Yes, it is required! omdb made this a requirement as of May 8, 2017. This is unfortunate,
but totally understandable. While I plan on working on finding an alternative to provide
the movie info you crave, I've enabled you to pass in an apikey.
You can get one by going [here](https://www.patreon.com/posts/api-is-going-10743518).
## Why? There are like 3 other interfaces to imdb in npm

@@ -160,0 +168,0 @@

@@ -27,2 +27,6 @@ /// <reference path="../typings/index.d.ts"/>

export interface MovieOpts {
apiKey: string;
}
export interface MovieRequest {

@@ -32,2 +36,3 @@ name?: string;

year?: number;
opts: MovieOpts;
}

@@ -122,2 +127,3 @@

private _episodes: Episode[] = [];
private _apikey: string;
public start_year;

@@ -127,3 +133,3 @@ public end_year;

constructor (object: OmdbTvshow) {
constructor (object: OmdbTvshow, apiKey: string) {
super(object);

@@ -134,2 +140,3 @@ let years = this["_year_data"].split("-");

this.totalseasons = parseInt(this["totalseasons"]);
this._apikey = apiKey;
}

@@ -146,3 +153,3 @@

for (let i = 1; i <= tvShow.totalseasons; i++) {
funcs.push(rp({"qs": {"i": tvShow.imdbid, "r": "json", "Season": i}, "json": true, "url": omdbapi}));
funcs.push(rp({"qs": {"apikey": tvShow._apikey, "i": tvShow.imdbid, "r": "json", "Season": i}, "json": true, "url": omdbapi}));
}

@@ -196,4 +203,14 @@

export function getReq(req: MovieRequest, cb?: (err: Error, data: Movie | Episode) => any) {
if (req.opts === undefined || ! req.opts.hasOwnProperty("apiKey")) {
let err = new ImdbError("Missing api key in opts", req);
if (cb) {
return cb(err, undefined);
} else {
return Promise.reject(err);
}
}
let responseData = "";
let qs = {plot: "full", r: "json", y: req.year};
let qs = {apikey: req.opts.apiKey, plot: "full", r: "json", y: req.year};

@@ -219,3 +236,3 @@ if (req.name) {

} else if (isTvshow(data)) {
ret = new TVShow(data);
ret = new TVShow(data, req.opts.apiKey);
} else if (isEpisode(data)) {

@@ -249,8 +266,8 @@ ret = new Episode(data, 30);

export function get(name: string, cb?: (err: Error, data: Movie) => any): Promise<Movie> {
return getReq({id: undefined, name: name }, cb);
export function get(name: string, opts: MovieOpts, cb?: (err: Error, data: Movie) => any): Promise<Movie> {
return getReq({id: undefined, opts: opts, name: name }, cb);
}
export function getById(imdbid: string, cb?: (err: Error, data: Movie) => any): Promise<Movie> {
return getReq({id: imdbid, name: undefined}, cb);
export function getById(imdbid: string, opts: MovieOpts, cb?: (err: Error, data: Movie) => any): Promise<Movie> {
return getReq({id: imdbid, opts: opts, name: undefined}, cb);
}

@@ -8,99 +8,130 @@ var https = require('https');

module.exports.testGetSuccessful = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=The%20Toxic%20Avenger').reply(200, require('./data/toxic-avenger.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=The%20Toxic%20Avenger').reply(200, require('./data/toxic-avenger.json'));
return imdb.get('The Toxic Avenger', testResults);
return imdb.get('The Toxic Avenger', {
apiKey: "foo"
}, testResults);
function testResults(err, data) {
test.ifError(err);
function testResults(err, data) {
test.ifError(err);
test.ok(data);
test.equal(data.imdbid, 'tt0090191', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.ok(data);
test.equal(data.imdbid, 'tt0090191', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.done();
}
}
test.done();
}
};
module.exports.testGetUnsuccessful = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=The%20Green%20Mile').reply(404);
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=The%20Green%20Mile').reply(404);
return imdb.get('The Green Mile', testResults);
return imdb.get('The Green Mile', {
apiKey: "foo"
}, testResults);
function testResults(err, data) {
test.ifError(data);
function testResults(err, data) {
test.ifError(data);
test.done();
}
}
test.done();
}
};
module.exports.testGetMadeupMovie = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=asdfasdfasdf').reply(200, { Response: "False", Error: "Movie not found!" });
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=asdfasdfasdf').reply(200, {
Response: "False",
Error: "Movie not found!"
});
return imdb.get('asdfasdfasdf', testResults);
return imdb.get('asdfasdfasdf', {
apiKey: "foo"
}, testResults);
function testResults(err, data) {
test.ifError(data);
function testResults(err, data) {
test.ifError(data);
test.deepEqual(err, new imdb.ImdbError('Movie not found!: asdfasdfasdf', { name:'asdfasdfasdf', id: undefined }), "testing film not found error");
test.deepEqual(err, new imdb.ImdbError('Movie not found!: asdfasdfasdf', {
name: 'asdfasdfasdf',
id: undefined,
opts: {
apiKey: "foo"
}
}), "testing film not found error");
test.done();
}
}
test.done();
}
};
module.exports.testGetEpisodes = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=How%20I%20Met%20Your%20Mother').reply(200, require('./data/how-I-met-your-mother.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=How%20I%20Met%20Your%20Mother').reply(200, require('./data/how-I-met-your-mother.json'));
return imdb.get('How I Met Your Mother', testResults);
return imdb.get('How I Met Your Mother', {
apiKey: "foo"
}, testResults);
function testResults(err, tvshow) {
var scope = nock('https://www.omdbapi.com').get('/?i=tt0460649&r=json&Season=1').reply(200, require('./data/how-I-met-your-mother-episodes.json'));
test.ifError(err);
function testResults(err, tvshow) {
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&i=tt0460649&r=json&Season=1').reply(200, require('./data/how-I-met-your-mother-episodes.json'));
test.ifError(err);
test.ok(tvshow);
test.equal(tvshow.start_year, 2005, "testing start_year");
test.equal(tvshow.end_year, null, "testing end_year");
test.equal(tvshow.year, null, "testing year is null");
test.equal(typeof(tvshow.episodes), "function", "testing for episodes function");
test.equal(tvshow.series, true, "testing series bool");
test.ok(tvshow);
test.equal(tvshow.start_year, 2005, "testing start_year");
test.equal(tvshow.end_year, null, "testing end_year");
test.equal(tvshow.year, null, "testing year is null");
test.equal(typeof(tvshow.episodes), "function", "testing for episodes function");
test.equal(tvshow.series, true, "testing series bool");
return tvshow.episodes(function(err, data) { testEpisodes(err, data, tvshow); });
}
return tvshow.episodes(function(err, data) {
testEpisodes(err, data, tvshow);
});
}
function testEpisodes(err, data, tvshow) {
test.ifError(err);
function testEpisodes(err, data, tvshow) {
test.ifError(err);
test.ok(data);
test.equal(data[0].season, 1, "testing a random value");
test.equal(data[0].episode, 1, "testing another value");
test.equal(data[0].name, "Pilot", "testing episode title");
test.equal(data[0].released.getTime(), new Date(2005, 8, 19).getTime(), "testing release date");
test.ok(data);
test.equal(data[0].season, 1, "testing a random value");
test.equal(data[0].episode, 1, "testing another value");
test.equal(data[0].name, "Pilot", "testing episode title");
test.equal(data[0].released.getTime(), new Date(2005, 8, 19).getTime(), "testing release date");
test.equal(typeof(tvshow._episodes), "object", "testing type of _episodes");
test.equal(tvshow._episodes[0].season, 1, "testing cached value");
test.equal(tvshow._episodes[0].episode, 1, "testing another cached value");
test.equal(typeof(tvshow._episodes), "object", "testing type of _episodes");
test.equal(tvshow._episodes[0].season, 1, "testing cached value");
test.equal(tvshow._episodes[0].episode, 1, "testing another cached value");
test.done();
}
}
test.done();
}
};
module.exports.testUnsuccessfulGetEpisodes = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=How%20I%20Met%20Your%20Mother').reply(200, require('./data/how-I-met-your-mother.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=How%20I%20Met%20Your%20Mother').reply(200, require('./data/how-I-met-your-mother.json'));
return imdb.get('How I Met Your Mother', testResults);
return imdb.get('How I Met Your Mother', {
apiKey: "foo"
}, testResults);
function testResults(err, data) {
var scope = nock('https://www.omdbapi.com').get('/?i=tt0460649&r=json&Season=1').reply(404);
function testResults(err, data) {
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&i=tt0460649&r=json&Season=1').reply(404);
test.ifError(err);
test.ok(data);
test.ifError(err);
test.ok(data);
return data.episodes(testEpisodes);
}
return data.episodes(testEpisodes);
}
function testEpisodes(err, data) {
test.ifError(data);
function testEpisodes(err, data) {
test.ifError(data);
test.done();
}
}
test.done();
}
};
module.exports.testNoApiKey = function(test) {
return imdb.get("foo", {}, testResults);
function testResults(err, data) {
test.ifError(data);
test.done();
}
};

@@ -10,43 +10,57 @@ "use strict";

module.exports.testGetByIdSuccessful = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&i=tt0090191').reply(200, require('./data/toxic-avenger.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&i=tt0090191').reply(200, require('./data/toxic-avenger.json'));
return imdb.getById('tt0090191', testResults);
return imdb.getById('tt0090191', {
apiKey: "foo"
}, testResults);
function testResults(err, data) {
test.ifError(err);
function testResults(err, data) {
test.ifError(err);
test.ok(data);
test.equal(data.title, 'The Toxic Avenger', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.ok(data);
test.equal(data.title, 'The Toxic Avenger', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.done();
}
}
test.done();
}
};
module.exports.testGetByIdUnsuccessful = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&i=tt0090190').reply(404);
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&i=tt0090190').reply(404);
return imdb.getById('tt0090190', testResults);
return imdb.getById('tt0090190', {
apiKey: "foo"
}, testResults);
function testResults(err, data) {
test.ifError(data);
function testResults(err, data) {
test.ifError(data);
test.done();
}
}
test.done();
}
};
module.exports.testGetMadeupMovie = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&i=tt0090190').reply(200, { Response: "False", Error: "Movie not found!" });
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&i=tt0090190').reply(200, {
Response: "False",
Error: "Movie not found!"
});
return imdb.getById('tt0090190', testResults);
return imdb.getById('tt0090190', {
apiKey: "foo"
}, testResults);
function testResults(err, data) {
test.ifError(data);
function testResults(err, data) {
test.ifError(data);
test.deepEqual(err, new imdb.ImdbError('Movie not found!: tt0090190', { id: 'tt0090190', name: undefined }), "testing film not found error");
test.deepEqual(err, new imdb.ImdbError('Movie not found!: tt0090190', {
id: 'tt0090190',
name: undefined,
opts: {
apiKey: "foo"
}
}), "testing film not found error");
test.done();
}
}
test.done();
}
};

@@ -8,55 +8,76 @@ var https = require('https');

module.exports.testGetReqSuccessful = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=The%20Toxic%20Avenger').reply(200, require('./data/toxic-avenger.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=The%20Toxic%20Avenger').reply(200, require('./data/toxic-avenger.json'));
return imdb.getReq({name: 'The Toxic Avenger'}, testResults);
return imdb.getReq({
name: 'The Toxic Avenger',
opts: {
apiKey: "foo"
}
}, testResults);
function testResults(err, data) {
test.ifError(err);
function testResults(err, data) {
test.ifError(err);
test.ok(data);
test.equal(data.imdbid, 'tt0090191', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.ok(data);
test.equal(data.imdbid, 'tt0090191', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.done();
}
}
test.done();
}
};
module.exports.testGetByReqIdSuccessful = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&i=tt0090191').reply(200, require('./data/toxic-avenger.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&i=tt0090191').reply(200, require('./data/toxic-avenger.json'));
return imdb.getReq({id: 'tt0090191'}, testResults);
return imdb.getReq({
id: 'tt0090191',
opts: {
apiKey: "foo"
}
}, testResults);
function testResults(err, data) {
test.ifError(err);
function testResults(err, data) {
test.ifError(err);
test.ok(data);
test.equal(data.title, 'The Toxic Avenger', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.ok(data);
test.equal(data.title, 'The Toxic Avenger', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.done();
}
}
test.done();
}
};
module.exports.testGetByReqYear = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&y=2015&t=James%20Bond').reply(200, require('./data/james-bond.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&y=2015&t=James%20Bond').reply(200, require('./data/james-bond.json'));
return imdb.getReq({name: 'James Bond', year: 2015}, testResults);
return imdb.getReq({
name: 'James Bond',
year: 2015,
opts: {
apiKey: "foo"
}
}, testResults);
function testResults(err, data) {
test.ifError(err);
function testResults(err, data) {
test.ifError(err);
test.ok(data);
test.equal(data.title, 'James Bond', "testing returned data");
test.equal(data.year, 2015, "testing correct year");
test.ok(data);
test.equal(data.title, 'James Bond', "testing returned data");
test.equal(data.year, 2015, "testing correct year");
test.done();
}
}
test.done();
}
};
module.exports.testGetEpisode = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&i=tt0869673').reply(200, require('./data/mother-ep.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&i=tt0869673').reply(200, require('./data/mother-ep.json'));
return imdb.getReq({id: 'tt0869673'}, testResults);
return imdb.getReq({
id: 'tt0869673',
opts: {
apiKey: "foo"
}
}, testResults);

@@ -67,7 +88,7 @@ function testResults(err, data) {

test.ok(data);
test.equal(data.name, 'The Scorpion and the Toad', "testing returned title");
test.equal(data.year, 2006, "testing correct year");
test.equal(data.name, 'The Scorpion and the Toad', "testing returned title");
test.equal(data.year, 2006, "testing correct year");
test.done();
test.done();
}
}
};

@@ -8,11 +8,13 @@ var https = require('https');

module.exports.testPromise = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=The%20Toxic%20Avenger').reply(200, require('./data/toxic-avenger.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=The%20Toxic%20Avenger').reply(200, require('./data/toxic-avenger.json'));
return imdb.get('The Toxic Avenger').then(function(data) {
test.ok(data);
test.equal(data.imdbid, 'tt0090191', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
return imdb.get('The Toxic Avenger', {
apiKey: "foo"
}).then(function(data) {
test.ok(data);
test.equal(data.imdbid, 'tt0090191', "testing returned data");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");
test.done();
test.done();
}).catch(function(err) {

@@ -22,8 +24,10 @@ test.ifError(err);

});
}
};
module.exports.testUnsuccessfulPromise = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=The%20Toxic%20Avenger').reply(404);
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=The%20Toxic%20Avenger').reply(404);
return imdb.get('The Toxic Avenger').then(function(data) {
return imdb.get('The Toxic Avenger', {
apiKey: "foo"
}).then(function(data) {
test.ifError(data);

@@ -35,12 +39,14 @@ test.done();

});
}
};
module.exports.testEpisodes = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=How%20I%20Met%20Your%20Mother').reply(200, require('./data/how-I-met-your-mother.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=How%20I%20Met%20Your%20Mother').reply(200, require('./data/how-I-met-your-mother.json'));
return imdb.get('How I Met Your Mother').then(function(data) {
var scope = nock('https://www.omdbapi.com').get('/?i=tt0460649&r=json&Season=1').reply(200, require('./data/how-I-met-your-mother-episodes.json'));
return imdb.get('How I Met Your Mother', {
apiKey: "foo"
}).then(function(data) {
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&i=tt0460649&r=json&Season=1').reply(200, require('./data/how-I-met-your-mother-episodes.json'));
test.ok(data);
data.episodes().then(function (eps) {
data.episodes().then(function(eps) {
test.ok(eps);

@@ -50,16 +56,18 @@ test.done();

});
}
};
module.exports.testUnsuccessfulEpisodes = function(test) {
var scope = nock('https://www.omdbapi.com').get('/?plot=full&r=json&t=How%20I%20Met%20Your%20Mother').reply(200, require('./data/how-I-met-your-mother.json'));
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&plot=full&r=json&t=How%20I%20Met%20Your%20Mother').reply(200, require('./data/how-I-met-your-mother.json'));
return imdb.get('How I Met Your Mother').then(function(data) {
var scope = nock('https://www.omdbapi.com').get('/?i=tt0460649&r=json&Season=1').reply(404);
return imdb.get('How I Met Your Mother', {
apiKey: "foo"
}).then(function(data) {
var scope = nock('https://www.omdbapi.com').get('/?apikey=foo&i=tt0460649&r=json&Season=1').reply(404);
test.ok(data);
data.episodes().then(function (eps) {
data.episodes().then(function(eps) {
test.ifError(eps);
test.done();
}).catch(function (err) {
}).catch(function(err) {
test.ok(err);

@@ -69,2 +77,2 @@ test.done();

});
}
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc