balena-request
Advanced tools
Comparing version 11.5.5-thgreasi-patch-1ssdasd-322148470c6d0ad199a3df362f818a0186c55cf3 to 11.5.5-thgreasi-patch-1ssdasd-78dff444e207df7d6838f0e8bdf25b8673c065d6
{ | ||
"name": "balena-request", | ||
"version": "11.5.5-thgreasi-patch-1ssdasd-322148470c6d0ad199a3df362f818a0186c55cf3", | ||
"version": "11.5.5-thgreasi-patch-1ssdasd-78dff444e207df7d6838f0e8bdf25b8673c065d6", | ||
"description": "Balena HTTP client", | ||
@@ -73,4 +73,4 @@ "main": "build/request.js", | ||
"versionist": { | ||
"publishedAt": "2022-04-06T15:17:18.861Z" | ||
"publishedAt": "2022-04-06T15:35:41.370Z" | ||
} | ||
} |
@@ -159,3 +159,3 @@ const ReadableStream = require('stream').Readable; | ||
describe('given a response with a string error property', function () { | ||
describe('given a response with a string message property', function () { | ||
beforeEach(function () { | ||
@@ -170,8 +170,40 @@ return (this.response = { | ||
it('should print the error.text property', function () { | ||
it('should print the body.message property', function () { | ||
const error = utils.getErrorMessageFromResponse(this.response); | ||
return expect(error).to.deep.equal(this.response.body); | ||
expect(error).to.deep.equal(this.response.body.message); | ||
}); | ||
}); | ||
describe('given a response with a string error property', function () { | ||
beforeEach(function () { | ||
return (this.response = { | ||
body: { | ||
error: 'errorTypeSlug', | ||
}, | ||
}); | ||
}); | ||
it('should print the body.error property', function () { | ||
const error = utils.getErrorMessageFromResponse(this.response); | ||
expect(error).to.deep.equal(this.response.body.error); | ||
}); | ||
}); | ||
// TODO: Improve this so that we can drop this test case | ||
describe('given a response with an object response w/o any known message property', function () { | ||
beforeEach(function () { | ||
return (this.response = { | ||
body: { | ||
error2: 'errorTypeSlug', | ||
message2: 'More details about the error', | ||
}, | ||
}); | ||
}); | ||
it('should return the whole body', function () { | ||
const error = utils.getErrorMessageFromResponse(this.response); | ||
expect(error).to.deep.equal(this.response.body); | ||
}); | ||
}); | ||
describe('given a response without an error object', function () { | ||
@@ -178,0 +210,0 @@ beforeEach(function () { |
Sorry, the diff of this file is not supported yet
202813
4010