import { mount } from '@vue/test-utils'; import { describe, expect, it } from 'vitest'; import { AppDropdownList } from '@components/common/dropdown-list'; describe('下拉列表框', () => { expect(AppDropdownList).toBeTruthy(); it('disabled', async () => { const wrapper = mount(AppDropdownList, { props: { disabled: true, }, }); expect(wrapper.find('.ant-select-disabled').exists()).toBeTruthy(); }); it('readonly', async () => { const wrapper = mount(AppDropdownList, { props: { readonly: true, }, }); expect(wrapper.find('.ant-select-disabled').exists()).toBeTruthy(); }); it('placeholder', async () => { const wrapper = mount(AppDropdownList, { props: { placeholder: '提示信息', }, }); const inputElm = wrapper.find('.ant-select-selection-placeholder') expect(inputElm.text()).toContain('提示信息'); }); it('multiple-valueSeparator', async () => { const options = [{ label: '文本1', value: '1' },{ label: '文本2', value: '2' },{ label: '文本3', value: '3' }] const wrapper = mount(AppDropdownList, { props: { multiple: true, valueSeparator: '-', value: '文本1-文本2' }, data() { return { items: options } } }); expect(wrapper.text()).toContain('文本1文本2'); }); it('clearable', async () => { const wrapper = mount(AppDropdownList, { props: { clearable: true, }, }); const select = wrapper.find('.ant-select') expect(select.classes()).toContain('ant-select-allow-clear'); }); it('filterable', async () => { const wrapper = mount(AppDropdownList, { props: { filterable: true, }, }); const select = wrapper.find('.ant-select') expect(select.classes()).toContain('ant-select-show-search'); }); it('editorStyle', async () => { const wrapper = mount(AppDropdownList, { props: { editorStyle: 'cascader', }, }); expect(wrapper.find('.ant-cascader').exists()).toBeTruthy(); }); });