Flesh out VerifyCode.spec.js

This commit is contained in:
Robert Schäfer 2019-06-18 13:13:13 +02:00
parent a641ab6884
commit 288e5002fd
3 changed files with 32 additions and 6 deletions

View File

@ -20,7 +20,7 @@ describe('VerifyCode ', () => {
$t: jest.fn(), $t: jest.fn(),
$apollo: { $apollo: {
loading: false, loading: false,
mutate: jest.fn().mockResolvedValue({ data: { resetPassword: false } }), mutate: jest.fn().mockResolvedValue({ data: { resetPassword: true } }),
}, },
} }
}) })
@ -50,9 +50,27 @@ describe('VerifyCode ', () => {
}) })
describe('submitting new password', () => { describe('submitting new password', () => {
it.todo('calls resetPassword graphql mutation') beforeEach(() => {
it.todo('delivers new password to backend') wrapper.find('input#newPassword').setValue('supersecret')
it.todo('displays success message') wrapper.find('input#confirmPassword').setValue('supersecret')
wrapper.find('form').trigger('submit')
})
it('calls resetPassword graphql mutation', () => {
expect(mocks.$apollo.mutate).toHaveBeenCalled()
})
it('delivers new password to backend', () => {
const expected = expect.objectContaining({ variables: { newPassword: 'supersecret' } })
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected)
})
describe('password reset successful', () => {
it('displays success message', () => {
const expected = 'verify-code.change-password.sucess'
expect(mocks.$t).toHaveBeenCalledWith(expected)
})
})
}) })
}) })
}) })

View File

@ -26,7 +26,11 @@
"form": { "form": {
"input": "Code eingeben", "input": "Code eingeben",
"description": "Öffne Deine E-Mail Postfach und gib den Code ein, den wir geschickt haben.", "description": "Öffne Deine E-Mail Postfach und gib den Code ein, den wir geschickt haben.",
"submit": "Sicherheitscode überprüfen" "submit": "Sicherheitscode überprüfen",
"change-password":{
"success": "Änderung des Passworts war erfolgreich",
"failure": "Passwort Änderung fehlgeschlagen. Möglicherweise falscher Sicherheitscode."
}
} }
}, },
"editor": { "editor": {

View File

@ -26,7 +26,11 @@
"form": { "form": {
"input": "Enter your code", "input": "Enter your code",
"description": "Open your inbox and enter the code that we've sent to you.", "description": "Open your inbox and enter the code that we've sent to you.",
"submit": "Check security code" "submit": "Check security code",
"change-password": {
"success": "Changing your password was successful",
"failure": "Changing your password failed. Probably the security code was not correct"
}
} }
}, },
"editor": { "editor": {