mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
complete unit tests for input email component
This commit is contained in:
parent
6ad6e0e4fa
commit
19ec650496
@ -1,6 +1,7 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
|
|
||||||
import InputEmail from './InputEmail'
|
import InputEmail from './InputEmail'
|
||||||
|
import flushPromises from 'flush-promises'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
@ -60,10 +61,17 @@ describe('InputEmail', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('input value changes', () => {
|
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 () => {
|
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')).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')
|
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')
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -67,7 +67,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
normalizeEmail() {
|
normalizeEmail() {
|
||||||
this.emailFocused = false
|
this.emailFocused = false
|
||||||
this.form.email = this.form.email.trim()
|
this.currentValue = this.currentValue.trim()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user