mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-03-07 13:48:31 +08:00
test(transfer): add test (#925)
This commit is contained in:
parent
e9fb97e87d
commit
efa6484722
@ -1,8 +1,39 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { sleep } from 'seemly'
|
||||
import { NTransfer } from '../index'
|
||||
|
||||
describe('n-transfer', () => {
|
||||
it('should work with import on demand', () => {
|
||||
mount(NTransfer)
|
||||
})
|
||||
|
||||
it('should work with `disabled` prop', () => {
|
||||
const wrapper = mount(NTransfer, { props: { disabled: true } })
|
||||
expect(wrapper.find('.n-transfer').attributes('class')).toContain(
|
||||
'n-transfer--disabled'
|
||||
)
|
||||
})
|
||||
|
||||
it('should work with `filterable` prop', () => {
|
||||
const wrapper = mount(NTransfer, { props: { filterable: true } })
|
||||
expect(wrapper.find('.n-transfer').attributes('class')).toContain(
|
||||
'n-transfer--filterable'
|
||||
)
|
||||
})
|
||||
|
||||
it('should work with `filter` prop', async () => {
|
||||
const options = [
|
||||
{
|
||||
label: 'test1',
|
||||
value: 'test1'
|
||||
}
|
||||
]
|
||||
const onFilter = jest.fn()
|
||||
const wrapper = mount(NTransfer, {
|
||||
props: { filterable: true, filter: onFilter, options: options }
|
||||
})
|
||||
await wrapper.find('input').setValue('1')
|
||||
await sleep(300)
|
||||
expect(onFilter).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user