test regexp to catch error message

This commit is contained in:
Moriz Wahl 2022-03-23 16:16:04 +01:00
parent 40520c6718
commit b0300e5a08
2 changed files with 7 additions and 3 deletions

View File

@ -149,13 +149,17 @@ describe('ResetPassword', () => {
describe('server response with error code > 10min', () => {
beforeEach(async () => {
jest.clearAllMocks()
apolloMutationMock.mockRejectedValue({ message: '...Code is older than 10 minutes' })
apolloMutationMock.mockRejectedValue({
message: '...email was sent more than 23 hours and 10 minutes ago',
})
await wrapper.find('form').trigger('submit')
await flushPromises()
})
it('toasts an error message', () => {
expect(toastErrorSpy).toHaveBeenCalledWith('...Code is older than 10 minutes')
expect(toastErrorSpy).toHaveBeenCalledWith(
'...email was sent more than 23 hours and 10 minutes ago',
)
})
it('router pushes to /forgot-password/resetPassword', () => {

View File

@ -106,7 +106,7 @@ export default {
this.toastError(error.message)
if (
error.message.match(
/email was sent more than ([0-9]+ hours)?( and)?([0-9]+ minutes)? ago/,
/email was sent more than ([0-9]+ hours)?( and )?([0-9]+ minutes)? ago/,
)
)
this.$router.push('/forgot-password/resetPassword')