test: configure namespace and zindex for loading (#12485)

This commit is contained in:
btea 2023-04-18 23:30:01 +08:00 committed by GitHub
parent 5cd6d61400
commit 32e8829d48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,27 @@
import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import { ElButton, ElLoading } from '@element-plus/components'
import ConfigProvider from '../src/config-provider'
import type { LoadingInstance } from '@element-plus/components/loading/src/loading'
describe('loading config', () => {
it('should render loading component', async () => {
let instance: LoadingInstance
const startLoading = () => {
instance = ElLoading.service()
}
const wrapper = mount(() => (
<ConfigProvider namespace="ep" zIndex={10000}>
<ElButton onClick={startLoading}>test</ElButton>
</ConfigProvider>
))
const btn = wrapper.find('.ep-button')
btn.trigger('click')
expect(btn).not.toBeNull()
const mask = document.querySelector<HTMLElement>('.ep-loading-mask')
expect(mask).not.toBeNull()
expect(mask?.style.zIndex).toBe('10001')
// @ts-expect-error
instance.close()
})
})