-
Notifications
You must be signed in to change notification settings - Fork 23
/
test.js
39 lines (29 loc) · 1.02 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var tap = require('tap').test,
omdb = require('./');
var SEARCH_PROPERTIES = [ 'title', 'year', 'imdb', 'type' ];
tap('correct searching', function (test) {
test.plan(2 + SEARCH_PROPERTIES.length);
omdb.search('saw', function (err, movies) {
var movie = movies[0];
test.notOk(err, 'no errors');
test.ok(!!movie, 'there is at least one movie');
SEARCH_PROPERTIES.forEach(function (property) {
test.ok(movie && movie[property], 'movie has ' + property);
});
});
});
tap('incorrect searching', function (test) {
test.plan(3);
omdb.search('gHwZjE9BqsbCYmjBFwqWTyWV', function (err, movies) {
test.notOk(err, 'no errors');
test.ok(Array.isArray(movies), 'movies is an array');
test.equals(movies.length, 0, 'movies array is empty');
});
});
tap('specific movie', function (test) {
test.plan(2);
omdb.get('tt0057012', function (err, movie) {
test.notOk(err, 'no errors');
test.ok(movie, 'movie exists');
});
});