2022-04-11 01:29:46 +00:00
|
|
|
import { expect } from 'chai'
|
2022-03-07 21:36:22 +00:00
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
describe('CharacterData', () => {
|
|
|
|
const target = {}
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
before(() => polyfill(target))
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Includes CharacterData functionality', () => {
|
|
|
|
expect(target).to.have.property('CharacterData')
|
|
|
|
expect(target).to.have.property('Text')
|
|
|
|
expect(target).to.have.property('Comment')
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Supports new Comment', () => {
|
|
|
|
expect(() => {
|
|
|
|
new target.Comment()
|
|
|
|
}).not.to.throw()
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
expect(new target.Comment().constructor.name).to.equal('Comment')
|
|
|
|
expect(Object.prototype.toString.call(new target.Comment())).to.equal(
|
|
|
|
'[object Comment]'
|
|
|
|
)
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
expect(new target.Comment('hello').data).to.equal('hello')
|
|
|
|
expect(new target.Comment('hello').textContent).to.equal('hello')
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Supports new Text', () => {
|
|
|
|
expect(() => {
|
|
|
|
new target.Text()
|
|
|
|
}).not.to.throw()
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
expect(new target.Text().constructor.name).to.equal('Text')
|
|
|
|
expect(Object.prototype.toString.call(new target.Text())).to.equals(
|
|
|
|
'[object Text]'
|
|
|
|
)
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
expect(new target.Text('hello').data).to.equal('hello')
|
|
|
|
expect(new target.Text('hello').textContent).to.equal('hello')
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
})
|