mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
test(auto-complete): update test (#1365)
Co-authored-by: unknown <liyang@xiaoyouzi.com>
This commit is contained in:
parent
a2e5f557cb
commit
15c97c5ca7
@ -70,4 +70,33 @@ describe('n-auto-complete', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
||||
|
||||
it('should work with `getShow` prop', async () => {
|
||||
const options: AutoCompleteProps['options'] = [
|
||||
'@gmail.com',
|
||||
'@163.com',
|
||||
'@qq.com'
|
||||
].map((suffix) => {
|
||||
const prefix = 'test'
|
||||
return {
|
||||
label: prefix + suffix,
|
||||
value: prefix + suffix
|
||||
}
|
||||
})
|
||||
const wrapper = mount(NAutoComplete)
|
||||
await wrapper.setProps({
|
||||
getShow: (value: string | null) => {
|
||||
if (value === 'a') {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
options: options
|
||||
})
|
||||
expect(document.querySelector('.n-auto-complete-menu')).toEqual(null)
|
||||
wrapper.find('input').setValue('a')
|
||||
await wrapper.find('input').trigger('focus')
|
||||
expect(document.querySelector('.n-auto-complete-menu')).not.toEqual(null)
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user