diff --git a/frontend/src/components/Inputs/InputEmail.spec.js b/frontend/src/components/Inputs/InputEmail.spec.js index c0f4dabdd..91db1f307 100644 --- a/frontend/src/components/Inputs/InputEmail.spec.js +++ b/frontend/src/components/Inputs/InputEmail.spec.js @@ -1,6 +1,7 @@ import { mount } from '@vue/test-utils' import InputEmail from './InputEmail' +import flushPromises from 'flush-promises' const localVue = global.localVue @@ -60,10 +61,17 @@ describe('InputEmail', () => { }) describe('input value changes', () => { + it.skip('trims the email after blur', async () => { + await wrapper.find('input').setValue(' valid@email.com ') + await wrapper.find('input').trigger('blur') + await flushPromises() + expect(wrapper.vm.currentValue).toBe('valid@email.com') + }) + it('emits input with new value', async () => { - await wrapper.find('input').setValue('12') + await wrapper.find('input').setValue('user@example.org') expect(wrapper.emitted('input')).toBeTruthy() - expect(wrapper.emitted('input')).toEqual([['12']]) + expect(wrapper.emitted('input')).toEqual([['user@example.org']]) }) }) @@ -73,5 +81,13 @@ describe('InputEmail', () => { expect(wrapper.vm.currentValue).toEqual('user@example.org') }) }) + + describe('email normalization', () => { + it('is trimmed', async () => { + await wrapper.setData({ currentValue: ' valid@email.com ' }) + wrapper.vm.normalizeEmail() + expect(wrapper.vm.currentValue).toBe('valid@email.com') + }) + }) }) }) diff --git a/frontend/src/components/Inputs/InputEmail.vue b/frontend/src/components/Inputs/InputEmail.vue index a2d673d57..e7900141f 100644 --- a/frontend/src/components/Inputs/InputEmail.vue +++ b/frontend/src/components/Inputs/InputEmail.vue @@ -67,7 +67,7 @@ export default { methods: { normalizeEmail() { this.emailFocused = false - this.form.email = this.form.email.trim() + this.currentValue = this.currentValue.trim() }, }, }