import { defineComponent, nextTick } from 'vue' import { mount } from '@vue/test-utils' import { afterEach, describe, it } from 'vitest' import Options from '../src/options' import Select from '../src/select.vue' import type { PropType } from 'vue' import type { VueWrapper } from '@vue/test-utils' describe('options', () => { let wrapper: ReturnType const ElOptionStub = defineComponent({ name: 'ElOption', props: { label: String, value: [String, Number, Boolean, Object] as PropType< string | number | boolean | object >, }, template: '
', }) const getLabel = (i: number | string) => `label-${i}` const ElOptionGroupStub = defineComponent({ name: 'ElOptionGroup', props: { label: String, }, template: '
', }) const samples = Array.from({ length: 3 }) const createWrapper = (slots = {}) => { wrapper = mount( (_, { slots }) => ( ), { global: { components: { ElOption: ElOptionStub, ElOptionGroup: ElOptionGroupStub, }, }, slots, } ) as VueWrapper } afterEach(() => { wrapper.unmount() }) it('renders emit correct options', async () => { createWrapper({ default: () => samples.map((_, i) => ), }) await nextTick() }) it('renders emit correct options with option group', async () => { createWrapper({ default: () => samples.map((_, i) => ( {{ default: () => samples.map((_, j) => ( )), }} )), }) }) })