Repository: element-plus/element-plus
File: packages/components/mention/__tests__/mention.test.tsx (TypeScript)

Code before:
    const model = ref('')
    const wrapper = mount(
      () => <Mention v-model={model.value} options={optionsWithDisabled} />,
      { attachTo: document.body }
    )

    const inputEl = wrapper.find('input')
    inputEl.element.focus()
    await inputEl.setValue('@')

    vi.advanceTimersByTime(150)
    await nextTick()

    expect(document.querySelector('.el-mention-dropdown')).not.toEqual(null)

    const dropdown = wrapper.findComponent({ name: 'ElMentionDropdown' })
    const dropdownVm = dropdown.vm as any
    expect(dropdownVm.hoveringIndex).toBe(1)

    await inputEl.trigger('keydown', {
      code: EVENT_CODE.enter,
      key: EVENT_CODE.enter,
    })
    await nextTick()

    expect(inputEl.element.value).toBe('@kooriookami ')
  })

  test('should not select disabled option when pressing enter', async () => {
    const model = ref('')
    const wrapper = mount(
      () => <Mention v-model={model.value} options={optionsWithDisabled} />,
      { attachTo: document.body }
    )

    const inputEl = wrapper.find('input')
    inputEl.element.focus()
    await inputEl.setValue('@')

    vi.advanceTimersByTime(150)
    await nextTick()

    expect(document.querySelector('.el-mention-dropdown')).not.toEqual(null)

    const dropdown = wrapper.findComponent({ name: 'ElMentionDropdown' })
    const dropdownVm = dropdown.vm as any
    dropdownVm.hoveringIndex = 0

    await nextTick()

    const dropdownItems = document.querySelectorAll(

Review comment (suggestion):
```suggestion
    expect(inputEl.element.value).toBe('@kooriookami ')
    expect(model.value).toBe('@kooriookami ')
```

Code after:
    const model = ref('')
    const wrapper = mount(
      () => <Mention v-model={model.value} options={optionsWithDisabled} />,
      { attachTo: document.body }
    )

    const inputEl = wrapper.find('input')
    inputEl.element.focus()
    await inputEl.setValue('@')

    vi.advanceTimersByTime(150)
    await nextTick()

    expect(document.querySelector('.el-mention-dropdown')).not.toEqual(null)

    const dropdown = wrapper.findComponent({ name: 'ElMentionDropdown' })
    const dropdownVm = dropdown.vm as any
    expect(dropdownVm.hoveringIndex).toBe(1)

    await inputEl.trigger('keydown', {
      code: EVENT_CODE.enter,
      key: EVENT_CODE.enter,
    })
    await nextTick()

    expect(inputEl.element.value).toBe('@kooriookami ')
    expect(model.value).toBe('@kooriookami ')
  })

  test('should not select disabled option when pressing enter', async () => {
    const model = ref('')
    const wrapper = mount(
      () => <Mention v-model={model.value} options={optionsWithDisabled} />,
      { attachTo: document.body }
    )

    const inputEl = wrapper.find('input')
    inputEl.element.focus()
    await inputEl.setValue('@')

    vi.advanceTimersByTime(150)
    await nextTick()

    expect(document.querySelector('.el-mention-dropdown')).not.toEqual(null)

    const dropdown = wrapper.findComponent({ name: 'ElMentionDropdown' })
    const dropdownVm = dropdown.vm as any
    dropdownVm.hoveringIndex = 0

    await nextTick()