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

Refactor/try catch unknown #1162

Merged
merged 5 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix test to actually throw an error
  • Loading branch information
tomrule007 committed Oct 25, 2021
commit eda25525a2126fff4f76fb512b1ae1561905c19a
6 changes: 2 additions & 4 deletions helpers/controllers/alertController.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ describe('Alert controller tests', () => {
expect(removeAlert({}, { id: 5 }, ctx)).resolves.toEqual({ success: true })
})
test('Should throw error if no id provided when removing alert', async () => {
prismaMock.alert.delete.mockRejectedValueOnce('No alert id provided')
expect(removeAlert({}, {}, ctx)).rejects.toThrowError(
'No alert id provided'
)
prismaMock.alert.delete.mockRejectedValueOnce(new Error('Some Error')) // Actually is a prisma RecordNotFound Error
expect(removeAlert({}, {}, ctx)).rejects.toThrowError()
})
})
2 changes: 1 addition & 1 deletion helpers/controllers/authController.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('auth controller', () => {
return expect(isTokenValid(null, userArgs)).resolves.toBe(false)
})
test('should throw error', () => {
prismaMock.user.findUnique.mockRejectedValue()
prismaMock.user.findUnique.mockRejectedValue(new Error('Some Error'))
return expect(isTokenValid(null, userArgs)).rejects.toThrowError()
})
})
Expand Down