-
Notifications
You must be signed in to change notification settings - Fork 10
Add a utils.assertSaneResponse method #139
Add a utils.assertSaneResponse method #139
Conversation
a219702
to
b6f7ecb
Compare
b6f7ecb
to
1399239
Compare
1399239
to
a3dd122
Compare
Low priority, so moving to Beta 6. |
a3dd122
to
b133db4
Compare
utils.js
Outdated
* | ||
* @param {ChakramResponse} response Object to check. | ||
*/ | ||
assertSaneResponse: function assertSaneResponse(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we want to also assertSaneResponse for _oauthRequest as well? That doesn't necessarily have to be done in this PR, but it's just something to think about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I should definitely do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve the changes. I left some comments for @rhoggSugarcrm to review at his convenience, but they do not block the ability to merge this PR.
b133db4
to
0d9d75a
Compare
utils.js
Outdated
*/ | ||
assertSaneResponse: function assertSaneResponse(response) { | ||
if (!response) { | ||
throw new Error('Undefined response received!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually need to change this, I shouldn't say something is undefined if it could be some other falsy value.
0d9d75a
to
5e25fed
Compare
5e25fed
to
7a36bd8
Compare
7a36bd8
to
75811e1
Compare
75811e1
to
c942303
Compare
c942303
to
9dbb988
Compare
9dbb988
to
3eac4e6
Compare
3eac4e6
to
63e457b
Compare
63e457b
to
357e0a9
Compare
357e0a9
to
8593650
Compare
tests/utils.js
Outdated
@@ -107,6 +107,20 @@ describe('Utils', () => { | |||
}); | |||
}); | |||
|
|||
describe('assertSaneResponse', () => { | |||
it('should throw on falsy response', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the same naming pattern as in other test cases, namely: it should thrown an error ...
?
tests/utils.js
Outdated
expect(() => { utils.assertSaneResponse(undefined); }).to.throw('Falsy response received!'); | ||
}); | ||
|
||
it('should throw if response.response does not exist', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here.
utils.js
Outdated
@@ -21,6 +21,21 @@ let chakram = require('chakram'); | |||
*/ | |||
let utils = { | |||
/** | |||
* Ensure that a Chakram response object is sane before using it. | |||
* Throws if the response is unreasonable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throws an error
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple suggestions, mainly nitpicks, otherwise looks great 👍
Signed-off-by: Bob Wombat Hogg <rhogg@sugarcrm.com>
This is the same as #109, but migrated to my new fork.