mirror of
https://github.com/element-plus/element-plus.git
synced 2025-12-19 09:09:40 +08:00
* test(utils): [vue] add icon,install,vnode and global-node test * test(utils): [global-node] remove repeat code of useless
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { afterEach, describe, expect, it } from 'vitest'
|
|
import {
|
|
changeGlobalNodesTarget,
|
|
createGlobalNode,
|
|
removeGlobalNode,
|
|
} from '../..'
|
|
|
|
describe('global-nodes', () => {
|
|
afterEach(() => {
|
|
document.body.innerHTML = ''
|
|
})
|
|
|
|
it('should create nodes to the root element', () => {
|
|
const el = createGlobalNode()
|
|
|
|
expect(el).not.toBeNull()
|
|
|
|
expect(document.body.firstChild).toBe(el)
|
|
})
|
|
|
|
it('should remove the recent created element', () => {
|
|
const el = createGlobalNode()
|
|
|
|
expect(document.body.firstElementChild).toBe(el)
|
|
|
|
removeGlobalNode(el)
|
|
|
|
expect(document.body.children).toHaveLength(0)
|
|
})
|
|
|
|
it('should change the target of created element', () => {
|
|
const target = createGlobalNode()
|
|
|
|
expect(document.body.firstElementChild).toBe(target)
|
|
|
|
const el = createGlobalNode()
|
|
|
|
expect(el.parentElement).toBe(document.body)
|
|
|
|
changeGlobalNodesTarget(target)
|
|
|
|
expect(el.parentElement).toBe(target)
|
|
})
|
|
|
|
it('should create node with id', () => {
|
|
const myId = 'my-id'
|
|
const el = createGlobalNode(myId)
|
|
|
|
expect(el).not.toBeNull()
|
|
|
|
expect(el.getAttribute('id')).toBe(myId)
|
|
})
|
|
})
|