diff --git a/webapp/components/Password/Change.spec.js b/webapp/components/Password/Change.spec.js index 98a66da72..e54514d78 100644 --- a/webapp/components/Password/Change.spec.js +++ b/webapp/components/Password/Change.spec.js @@ -1,5 +1,5 @@ import { mount, createLocalVue } from '@vue/test-utils' -import ChangePassword from './ChangePassword.vue' +import ChangePassword from './Change.vue' import Vue from 'vue' import Styleguide from '@human-connection/styleguide' @@ -10,6 +10,7 @@ localVue.use(Styleguide) describe('ChangePassword.vue', () => { let mocks let wrapper + let data beforeEach(() => { mocks = { @@ -34,7 +35,7 @@ describe('ChangePassword.vue', () => { describe('mount', () => { let wrapper const Wrapper = () => { - return mount(ChangePassword, { mocks, localVue }) + return mount(ChangePassword, { mocks, localVue, data }) } beforeEach(() => { @@ -97,8 +98,8 @@ describe('ChangePassword.vue', () => { }) describe('submit form', () => { - beforeEach(() => { - wrapper.find('form').trigger('submit') + beforeEach(async () => { + await wrapper.find('form').trigger('submit') }) it('calls changePassword mutation', () => { @@ -119,18 +120,19 @@ describe('ChangePassword.vue', () => { describe('mutation resolves', () => { beforeEach(() => { - mocks.$apollo.mutate = jest.fn().mockResolvedValue() - wrapper = Wrapper() + wrapper.find('form').trigger('submit') + // mocks.$apollo.mutate = jest.fn().mockResolvedValue() + // wrapper = Wrapper() }) - it('calls auth/SET_TOKEN with response', () => { + it('calls auth/SET_TOKEN with response', async () => { expect(mocks.$store.commit).toHaveBeenCalledWith( 'auth/SET_TOKEN', 'NEWTOKEN' ) }) - it('displays success message', () => { + it('displays success message', async () => { expect(mocks.$t).toHaveBeenCalledWith( 'settings.security.change-password.success' ) @@ -140,11 +142,16 @@ describe('ChangePassword.vue', () => { describe('mutation rejects', () => { beforeEach(() => { - // second call will reject - wrapper.find('form').trigger('submit') + wrapper.find('input#oldPassword').setValue('supersecret') + wrapper.find('input#newPassword').setValue('supersecret') + wrapper.find('input#confirmPassword').setValue('supersecret') }) - it('displays error message', () => { + it('displays error message', async () => { + await wrapper.find('form').trigger('submit') + await wrapper.find('form').trigger('submit') + await mocks.$apollo.mutate + expect(mocks.$toast.error).toHaveBeenCalledWith('Ouch!') }) }) diff --git a/webapp/components/Password/Change.vue b/webapp/components/Password/Change.vue index 742f5a1df..4998bbfb4 100644 --- a/webapp/components/Password/Change.vue +++ b/webapp/components/Password/Change.vue @@ -25,13 +25,15 @@ type="password" :label="$t('settings.security.change-password.label-new-password-confirm')" /> - + {{ $t('settings.security.change-password.button') }} + > + {{ $t('settings.security.change-password.button') }} + diff --git a/webapp/components/Password/Strength.vue b/webapp/components/Password/Strength.vue index e10f949f3..5368248d7 100644 --- a/webapp/components/Password/Strength.vue +++ b/webapp/components/Password/Strength.vue @@ -1,10 +1,16 @@