customizedBuiltIn.spec.ts 685 B

123456789101112131415161718192021
  1. import type { MockInstance } from 'vitest'
  2. import { h, render } from '@vue/runtime-dom'
  3. describe('customized built-in elements support', () => {
  4. let createElement: MockInstance
  5. afterEach(() => {
  6. createElement.mockRestore()
  7. })
  8. test('should created element with is option', () => {
  9. const root = document.createElement('div')
  10. createElement = vi.spyOn(document, 'createElement')
  11. render(h('button', { is: 'plastic-button' }), root)
  12. expect(createElement.mock.calls[0]).toMatchObject([
  13. 'button',
  14. { is: 'plastic-button' },
  15. ])
  16. // should also render the attribute
  17. expect(root.innerHTML).toBe(`<button is="plastic-button"></button>`)
  18. })
  19. })