2023-12-22 21:55:43 +08:00
|
|
|
import type { MockInstance } from 'vitest'
|
2020-03-28 00:38:47 +08:00
|
|
|
import { h, render } from '@vue/runtime-dom'
|
|
|
|
|
2020-05-01 21:42:58 +08:00
|
|
|
describe('customized built-in elements support', () => {
|
2023-12-22 21:55:43 +08:00
|
|
|
let createElement: MockInstance
|
2020-03-28 00:38:47 +08:00
|
|
|
afterEach(() => {
|
|
|
|
createElement.mockRestore()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('should created element with is option', () => {
|
|
|
|
const root = document.createElement('div')
|
2023-01-26 15:25:55 +08:00
|
|
|
createElement = vi.spyOn(document, 'createElement')
|
2020-03-28 00:38:47 +08:00
|
|
|
render(h('button', { is: 'plastic-button' }), root)
|
|
|
|
expect(createElement.mock.calls[0]).toMatchObject([
|
|
|
|
'button',
|
|
|
|
{ is: 'plastic-button' },
|
|
|
|
])
|
|
|
|
// should also render the attribute
|
|
|
|
expect(root.innerHTML).toBe(`<button is="plastic-button"></button>`)
|
|
|
|
})
|
|
|
|
})
|