New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API-789] Fix async unit tests #99
Conversation
const { fileId, mediaId, additional } = data; | ||
const { fileId, mediaId, additional, brandId } = data; | ||
|
||
if (!brandId && !mediaId) { |
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.
We need either the brandId (for a new asset) or the mediaId (for a newer version of an existing asset) to save an asset.
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.
But this condition is requesting both parameters to be defined.
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.
The condition is checking if both of them are undefined, hence the !
@@ -131,77 +129,65 @@ describe('#getToken', () => { | |||
|
|||
describe('#uploadFile', () => { | |||
it('throws an error with no brand ID', () => { | |||
bynder.uploadFile({ | |||
return expect(bynder.uploadFile({ |
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.
To make sure that jest waits for the promise to complete we need to either return the promise from the test, or await it. Also by the expect(...).rejects
pattern we ensure that the test fails if the promise were to resolve.
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.
https://bynder.atlassian.net/browse/API-789