Skip to content

Commit

Permalink
test(components): [select] add test for create and default first option
Browse files Browse the repository at this point in the history
  • Loading branch information
wzc520pyfm committed Apr 27, 2023
1 parent ba4da2f commit ab8d391
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/components/select/__tests__/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,41 @@ describe('Select', () => {
expect((wrapper.vm as any).value).toBe('new')
})

test('allow create with default first option', async () => {
wrapper = getSelectVm(
{
filterable: true,
allowCreate: true,
defaultFirstOption: true,
},
[
{
value: 'HTML',
label: 'HTML',
},
{
value: 'CSS',
label: 'CSS',
},
{
value: 'JavaScript',
label: 'JavaScript',
},
]
)
const select = wrapper.findComponent({ name: 'ElSelect' })
const selectVm = select.vm as any
const input = wrapper.find('input')
input.element.focus()
selectVm.selectedLabel = 'Java'
selectVm.debouncedOnInputChange()
await nextTick()
const options = [...getOptions()]
expect(Array.from(options[0].classList)).toContain('hover')
options[0].click()
expect((wrapper.vm as any).value).toBe('Java')
})

test('allow create async option', async () => {
const options = [
{
Expand Down

0 comments on commit ab8d391

Please sign in to comment.