Skip to content

Commit

Permalink
Fix unhandled rejections in the specs
Browse files Browse the repository at this point in the history
  • Loading branch information
lucassus committed Jan 29, 2017
1 parent bd73bde commit 431da02
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/open_subtitles_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ describe('OpenSubtitles', function() {

describe('.login', function() {

it('calls valid xmlrpc method', function() {
// When
openSubtitles.login();

// Then
var args = openSubtitles.xmlrpcClient.methodCall.lastCall.args;
expect(args[0]).to.eq('LogIn');
expect(args[1][2]).to.eq('en');
expect(args[1][3]).to.eq('OpenSubtitlesPlayer v4.7');
});

describe('on success', function() {

beforeEach(function() {
nock('http://api.opensubtitles.org').post('/xml-rpc')
.replyWithFile(200, helper.fixturePath('replies/login/success.xml'));
});

it('calls valid xmlrpc method', function() {
// When
openSubtitles.login();

// Then
var args = openSubtitles.xmlrpcClient.methodCall.lastCall.args;
expect(args[0]).to.eq('LogIn');
expect(args[1][2]).to.eq('en');
expect(args[1][3]).to.eq('OpenSubtitlesPlayer v4.7');
});

it('resolves the token', function() {
return openSubtitles.login().then(function(token) {
expect(token).to.eq('pboeg235h9ko7hf0h6567lk9i6');
Expand Down Expand Up @@ -110,15 +110,15 @@ describe('OpenSubtitles', function() {
it('calls valid xmlrpc method', function() {
// Given
nock('http://api.opensubtitles.org').post('/xml-rpc')
.reply(200);
.replyWithFile(200, helper.fixturePath('replies/check_movie_hash/success.xml'));

// When
openSubtitles.checkMovieHash('the hash');
openSubtitles.checkMovieHash('8e245d9679d31e12');

// Then
var args = openSubtitles.xmlrpcClient.methodCall.lastCall.args;
expect(args[0]).to.eq('CheckMovieHash');
expect(args[1][1]).to.deep.eq(['the hash']);
expect(args[1][1]).to.deep.eq(['8e245d9679d31e12']);
});

describe('on success', function() {
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('OpenSubtitles', function() {
it('calls valid xmlrpc method', function() {
// Given
nock('http://api.opensubtitles.org').post('/xml-rpc')
.reply(200);
.replyWithFile(200, helper.fixturePath('replies/get_imdb_movie_details/success.xml'));

// When
openSubtitles.getIMDBMovieDetails('0121766');
Expand Down

0 comments on commit 431da02

Please sign in to comment.