summaryrefslogtreecommitdiff
path: root/packages/webapi/test/internals.js
blob: 054b7e488faadc0e2714107ec03a710387dacd38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { expect } from 'chai'
import { polyfill } from '../mod.js'

it('Includes polyfill.internals functionality', () => {
	const target = {}

	polyfill(target, { exclude: 'window document' })

	const pseudo = { ...target }

	expect(pseudo).to.not.have.property('document')

	const CustomElement = class extends pseudo.HTMLElement {}

	pseudo.customElements.define('custom-element', CustomElement)

	polyfill.internals(pseudo, 'Document')

	expect(pseudo).to.have.property('document')

	expect(
		CustomElement.prototype.isPrototypeOf(
			pseudo.document.createElement('custom-element')
		)
	).to.equal(true)
})