0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00
astro/packages/webapi/test/characterdata.js
Nate Moore f18ee36dc0
Add @astrojs/webapi package (#2729)
* chore: add @astrojs/webapi

* chore: update package.json

* fix: update file case

* fix: remove lowercase file

* chore: update tests to use mocha

* chore: update LICENSE
2022-03-07 15:36:22 -06:00

59 lines
1.3 KiB
JavaScript

import { assert, test } from '../run/test.setup.js'
import { polyfill } from '../mod.js'
test(() => {
return [
{
name: 'Includes CharacterData functionality',
test() {
const target = {}
polyfill(target)
assert.equal(Reflect.has(target, 'CharacterData'), true)
assert.equal(Reflect.has(target, 'Text'), true)
assert.equal(Reflect.has(target, 'Comment'), true)
},
},
{
name: 'Throws new CharacterData',
test() {
const target = {}
polyfill(target)
},
},
{
name: 'Supports new Comment',
test() {
const target = polyfill({})
assert.doesNotThrow(() => {
new target.Comment()
})
assert.equal(new target.Comment().constructor.name, 'Comment')
assert.equal(Object.prototype.toString.call(new target.Comment()), '[object Comment]')
assert.equal(new target.Comment('hello').data, 'hello')
assert.equal(new target.Comment('hello').textContent, 'hello')
},
},
{
name: 'Supports new Text',
test() {
const target = polyfill({})
assert.doesNotThrow(() => {
new target.Text()
})
assert.equal(new target.Text().constructor.name, 'Text')
assert.equal(Object.prototype.toString.call(new target.Text()), '[object Text]')
assert.equal(new target.Text('hello').data, 'hello')
assert.equal(new target.Text('hello').textContent, 'hello')
},
},
]
})