From 93617dec23a95db9e05737b16b31eb7e5aa315b5 Mon Sep 17 00:00:00 2001 From: noodlefrenzy Date: Wed, 1 Oct 2014 12:00:00 -0700 Subject: [PATCH] Adding test for failure, removing spurious debugger statement. --- lib/bing.js | 1 - test/test.js | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/bing.js b/lib/bing.js index 3d35016..cdbd0df 100644 --- a/lib/bing.js +++ b/lib/bing.js @@ -51,7 +51,6 @@ var Bing = function( options ) { opts = _.extend(this.options, options); } - debugger; var reqUri = opts.rootUri + vertical + "?$format=json&" + qs.stringify({ "Query": "'" + query + "'" }); diff --git a/test/test.js b/test/test.js index 0b7a057..78d9bd1 100644 --- a/test/test.js +++ b/test/test.js @@ -70,4 +70,18 @@ describe('Bing', function() { 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(); + }); + }); }); \ No newline at end of file