diff --git a/frontend/src/components/Inputs/InputPasswordConfirmation.spec.js b/frontend/src/components/Inputs/InputPasswordConfirmation.spec.js new file mode 100644 index 000000000..ef3b5d64e --- /dev/null +++ b/frontend/src/components/Inputs/InputPasswordConfirmation.spec.js @@ -0,0 +1,79 @@ +import { mount } from '@vue/test-utils' +import { extend } from 'vee-validate' + +import InputPasswordConfirmation from './InputPasswordConfirmation' + +const rules = [ + 'containsLowercaseCharacter', + 'containsUppercaseCharacter', + 'containsNumericCharacter', + 'atLeastEightCharactera', + 'samePassword', +] + +rules.forEach((rule) => { + extend(rule, { + validate(value) { + return true + }, + }) +}) + +const localVue = global.localVue + +describe('InputPasswordConfirmation', () => { + let wrapper + + const propsData = { + value: { + password: '', + passwordRepeat: '', + }, + } + + const mocks = { + $t: jest.fn((t) => t), + } + + const Wrapper = () => { + return mount(InputPasswordConfirmation, { localVue, propsData, mocks }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('has two input fields', () => { + expect(wrapper.findAll('input')).toHaveLength(2) + }) + + describe('input values ', () => { + it('emits input with new value for first input field', async () => { + await wrapper.findAll('input').at(0).setValue('1234') + expect(wrapper.emitted('input')).toBeTruthy() + expect(wrapper.emitted('input')).toEqual([ + [ + { + password: '1234', + passwordRepeat: '', + }, + ], + ]) + }) + + it('emits input with new value for second input field', async () => { + await wrapper.findAll('input').at(1).setValue('1234') + expect(wrapper.emitted('input')).toBeTruthy() + expect(wrapper.emitted('input')).toEqual([ + [ + { + password: '', + passwordRepeat: '1234', + }, + ], + ]) + }) + }) + }) +}) diff --git a/frontend/src/components/Inputs/InputPasswordConfirmation.vue b/frontend/src/components/Inputs/InputPasswordConfirmation.vue new file mode 100644 index 000000000..08efaccfd --- /dev/null +++ b/frontend/src/components/Inputs/InputPasswordConfirmation.vue @@ -0,0 +1,68 @@ + + diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue index ba49662fd..00cacfd21 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue @@ -28,36 +28,8 @@ > - - - - - - - - - - - + +
@@ -75,11 +47,13 @@