Skip to content

Commit

Permalink
fix error message spacing and check in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed May 31, 2018
1 parent a2fec66 commit e221130
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/management/JobsManager.js
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ JobsManager.prototype.importUsers = function(data, cb) {
var type = (res.statusCode / 100) | 0;
var isErrorResponse = 4 === type || 5 === type;
if (isErrorResponse) {
var error = new Error('cannot ' + method + url + ' (' + res.statusCode + ')');
var error = new Error('cannot ' + method + ' ' + url + ' (' + res.statusCode + ')');
error.status = res.statusCode;
error.method = method;
error.text = res.text;
6 changes: 4 additions & 2 deletions test/management/jobs.tests.js
Original file line number Diff line number Diff line change
@@ -175,15 +175,17 @@ describe('JobsManager', function() {
.catch(done.bind(null, null));
});

it('should pass any errors to the promise catch handler', function(done) {
it('should pass HTTP errors to the promise catch handler', function(done) {
nock.cleanAll();

var request = nock(API_URL)
.post('/jobs/users-imports')
.reply(500);

this.jobs.importUsers(data).catch(function(err) {
expect(err).to.exist;
expect(err.message).to.equal(
'cannot POST https://tenant.auth0.com/jobs/users-imports (500)'
);
done();
});
});

0 comments on commit e221130

Please sign in to comment.