Skip to content
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

Merged
merged 3 commits into from
Oct 31, 2018
Merged

Conversation

ljewalsh
Copy link
Contributor

Also refactored how we were handling errors in general

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const error = await t.throwsAsync(addGroup(GROUP_NAME))
const error = await t.throwsAsync(
addGroup(GROUP_NAME),
GroupNameCharLimitExceeded
)

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure sure

@@ -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)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks!

@jladuval jladuval merged commit 7532c4b into master Oct 31, 2018
@jladuval jladuval deleted the check-group-length branch October 31, 2018 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants