test: add unit test

pull/7822/head
carl-chen 2024-09-06 00:04:48 +08:00
parent bbab81ab8c
commit 623490aad7
1 changed files with 24 additions and 0 deletions

View File

@ -177,4 +177,28 @@ describe('Select', () => {
expect(wrapper.html()).toMatchSnapshot();
});
});
describe('Select tags mode', () => {
it('Automatic word segmentation mode supports pasting.', async () => {
const wrapper = mount(Select, {
props: { mode: 'tags', tokenSeparators: [','] },
sync: false,
});
await asyncExpect(async () => {
const inputEl = wrapper.find('.ant-select-selection-search-input');
inputEl.setValue('1,2,3');
await inputEl.trigger('paste', {
clipboardData: {
getData: jest.fn().mockReturnValue('1,2,3'),
},
});
expect(inputEl.element.value).toBe('');
const tagsElements = wrapper.findAll('.ant-select-selection-item');
expect(tagsElements.length).toBe(3);
}, 100);
});
});
});