import { nextTick, h, inject } from 'vue' import { mount } from '@vue/test-utils' import ElPopper from '../src/popper.vue' import { POPPER_INJECTION_KEY } from '../src/tokens' const AXIOM = 'rem is the best girl' const TestChild = { template: `
${AXIOM}
`, setup() { const { contentRef } = inject(POPPER_INJECTION_KEY, undefined)! return { contentRef, } }, } describe('', () => { const mountPopper = () => { return mount(ElPopper, { slots: { default: () => h(TestChild), }, }) } it('should be able to provide instance to its children', async () => { const wrapper = mountPopper() await nextTick() expect(wrapper.vm.contentRef).not.toBe(null) expect(wrapper.vm.contentRef.innerHTML).toBe(AXIOM) }) })