Adding test for failure, removing spurious debugger statement.

This commit is contained in:
noodlefrenzy 2014-10-01 12:00:00 -07:00
parent ef9fa5de91
commit 93617dec23
2 changed files with 14 additions and 1 deletions

View file

@ -51,7 +51,6 @@ var Bing = function( options ) {
opts = _.extend(this.options, options); opts = _.extend(this.options, options);
} }
debugger;
var reqUri = opts.rootUri + vertical + var reqUri = opts.rootUri + vertical +
"?$format=json&" + "?$format=json&" +
qs.stringify({ "Query": "'" + query + "'" }); qs.stringify({ "Query": "'" + query + "'" });

View file

@ -70,4 +70,18 @@ describe('Bing', function() {
done(); done();
}); });
}); });
it('should cope with errors', function(done) {
// No actual data on what the failure looks like.
var failure = { message: 'Failed request' };
app.get('/hello/Image', function (req, res) {
res.status(500).send(JSON.stringify(failure));
});
var bingClient = bing({ rootUri: 'http://localhost:'+port+'/hello/', accKey: '123' });
bingClient.images('xbox', function (error, response, body) {
response.statusCode.should.eql(500);
body.should.eql(failure);
done();
});
});
}); });