-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adds error handling for group name length #6
Conversation
… name is more than 20 characters
src/requests/addGroup.spec.js
Outdated
test(`GroupNameCharLimitExceeded is thrown when the group name is too long`, async (t) => { | ||
const GROUP_NAME = 'hereisareallyreallylonggroupname' | ||
|
||
const error = await t.throwsAsync(addGroup(GROUP_NAME)) |
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.
const error = await t.throwsAsync(addGroup(GROUP_NAME)) | |
const error = await t.throwsAsync( | |
addGroup(GROUP_NAME), | |
GroupNameCharLimitExceeded | |
) |
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.
You can pass an error class as the second argument to throwsAsync
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.
Sure sure
src/requests/addLinkToGroup.spec.js
Outdated
@@ -37,5 +37,6 @@ test('If genius replies with 200 but LinkResponses contains an error message, th | |||
}] | |||
}) | |||
|
|||
await t.throws(addLinkToGroup(LINK, GROUP_ID), 'Genius API could not generate a code, but still came back with 200') | |||
const error = await t.throwsAsync(addLinkToGroup(LINK, GROUP_ID)) | |||
t.truthy(error instanceof AddLinkToGroupFailed) |
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 would suggest you use t.true
here -- as instanceof
returns a boolean.
But in this case, I would also suggest passing AddLinkToGroupFailed
directly to throwsAsync
as the second argument.
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.
ok thanks!
Also refactored how we were handling errors in general