mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* refactor(tokens): remove tokens * Remove tokens/breadcrumb. * refactor(tokens): remove tokens/button * refactor(tokens): remove tokens/carousel * refactor(tokens): removing tokens/checkbox * refactor(tokens): removing tokens/collapse * refactor(tokens): removing tokens/dialog * refactor(tokens): removing tokens/pagination * refactor(tokens): removing tokens/radio * refactor(tokens): removing tokens/row * refactor(tokens): removing tokens/scrollbar * refactor(tokens): removing tokens/slider * refactor(tokens): removing tokens/tabs * refactor(tokens): removing tokens/upload * refactor(tokens): removing tokens/popper * refactor(tokens): removing tokens/tooltip * refactor(tokens): removing tokens/tooltip-v2 * refactor(tokens): removing tokens/date-picker * refactor(project): removing tokens/experimentals * Remove tokens/experimentals * Remove package/tokens * Remove tokens related parts * refactor(project): removing packages/tokens completely * chore: update import statement
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { nextTick, ref } from 'vue'
|
|
import { mount } from '@vue/test-utils'
|
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
import { POPPER_CONTENT_INJECTION_KEY } from '@element-plus/components/popper'
|
|
import ElArrow from '../src/arrow.vue'
|
|
|
|
import type { VueWrapper } from '@vue/test-utils'
|
|
import type { PopperArrowInstance } from '../src/arrow'
|
|
|
|
const popperContentInjection = {
|
|
arrowRef: ref(null),
|
|
arrowOffset: ref(0),
|
|
}
|
|
|
|
const mountArrow = () =>
|
|
mount(<ElArrow />, {
|
|
global: {
|
|
provide: {
|
|
[POPPER_CONTENT_INJECTION_KEY as symbol]: popperContentInjection,
|
|
},
|
|
},
|
|
})
|
|
|
|
describe('<ElPopperArrow />', () => {
|
|
let wrapper: VueWrapper<PopperArrowInstance>
|
|
|
|
beforeEach(() => {
|
|
wrapper = mountArrow()
|
|
return nextTick()
|
|
})
|
|
|
|
afterEach(() => {
|
|
wrapper?.unmount()
|
|
popperContentInjection.arrowRef.value = null
|
|
popperContentInjection.arrowOffset.value = 0
|
|
})
|
|
|
|
it('should set the arrowRef after mounted', async () => {
|
|
expect(popperContentInjection.arrowRef.value).toBe(wrapper.vm.arrowRef)
|
|
expect(popperContentInjection.arrowOffset.value).toBe(0)
|
|
})
|
|
|
|
it('should update the offset after props changed', async () => {
|
|
expect(popperContentInjection.arrowOffset.value).toBe(0)
|
|
|
|
await wrapper.setProps({
|
|
arrowOffset: 10,
|
|
})
|
|
|
|
expect(popperContentInjection.arrowOffset.value).toBe(10)
|
|
})
|
|
|
|
it('should unset arrowRef before unmount', async () => {
|
|
expect(popperContentInjection.arrowRef.value).toBe(wrapper.vm.arrowRef)
|
|
|
|
wrapper.unmount()
|
|
expect(popperContentInjection.arrowRef.value).toBeNull()
|
|
})
|
|
})
|