test(components): [el-tooltip] add unit test about appendTo (#6178)

This commit is contained in:
weidehai 2022-02-21 09:12:29 +08:00 committed by GitHub
parent 4c4be8f951
commit 7e9ff25aea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -145,7 +145,6 @@ tooltip/animations
| Attribute | Description | Type | Accepted Values | Default |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| append-to | which element the tooltip CONTENT appends to | CSSSelector \| HTMLElement | — | #el-popper-container-[randomValue] |
| append-to-body (deprecated) | indicates whether the tooltip contents will be append to the document.body element | boolean | true / false | true |
| effect | Tooltip theme, built-in theme: `dark` / `light` | string | string | dark |
| content | display content, can be overridden by `slot#content` | String | — | — |
| raw-content | whether `content` is treated as HTML string | boolean | — | false |

View File

@ -41,6 +41,19 @@ describe('<ElTooltip />', () => {
await nextTick()
expect(findTrigger().text()).toContain(AXIOM)
})
it('content should teleport according appendTo', async () => {
const el = document.createElement('div')
el.id = 'test'
document.body.appendChild(el)
wrapper = createComponent({ appendTo: '#test' }, 'test appendTo props')
await nextTick()
const trigger$ = findTrigger()
const triggerEl = trigger$.find('.el-tooltip__trigger')
await triggerEl.trigger('mouseenter')
expect(document.querySelector('#test')?.innerHTML).toContain(
'test appendTo props'
)
})
})
describe('deprecating API', () => {