test(transfer): add test (#925)

This commit is contained in:
XieZongChen 2021-08-19 21:07:01 -05:00 committed by GitHub
parent e9fb97e87d
commit efa6484722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
})
})