From 623490aad72e1a244b403fc971ce041897414348 Mon Sep 17 00:00:00 2001 From: carl-chen Date: Fri, 6 Sep 2024 00:04:48 +0800 Subject: [PATCH] test: add unit test --- components/select/__tests__/index.test.js | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/components/select/__tests__/index.test.js b/components/select/__tests__/index.test.js index e169e107f..df775c6fa 100644 --- a/components/select/__tests__/index.test.js +++ b/components/select/__tests__/index.test.js @@ -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); + }); + }); });