More SSML test cases

This commit is contained in:
Jackson Harper 2022-08-30 12:21:10 +08:00
parent c85e6370b1
commit 0236f2b675

View file

@ -29,6 +29,36 @@ describe('htmlToSsml', () => {
)
})
})
describe('escaping', () => {
it('should convert   to spaces', async () => {
const ssml = htmlToSsml(`
<div id="readability-content">
<div id="readability-page-1">
<p>some&nbsp;&nbsp;space</p>
</div>
</div>
`, TEST_OPTIONS
)
const text = ssml[0].textItems.join('').trim()
expect(text).to.equal(
`<p><bookmark mark="3" />some space</p>`
)
})
it('should remove emojis', async () => {
const ssml = htmlToSsml(`
<div id="readability-content">
<div id="readability-page-1">
<p>no emoji here 🙏🙏</p>
</div>
</div>
`, TEST_OPTIONS
)
const text = ssml[0].textItems.join('').trim()
expect(text).to.equal(
`<p><bookmark mark="3" />no emoji here </p>`
)
})
})
describe('a file with nested elements', () => {
it('should collapse spans into the parent paragraph', async () => {
const ssml = htmlToSsml(`
@ -178,6 +208,38 @@ describe('htmlToSsml', () => {
)
})
})
describe('a file with lists', () => {
it('should convert a ul to <p> and <s>', async () => {
const ssml = htmlToSsml(`
<div id="readability-content">
<div>
<ul><li>first item</li><li>second item</li></ul>
</p>
</div>
</div>
`, TEST_OPTIONS
)
const text = ssml[0].textItems.join('').trim()
expect(text).to.equal(
`<p><s>first item</s><s>second item</s></p>`.trim()
)
})
it('should convert a ol to <p> and <s>', async () => {
const ssml = htmlToSsml(`
<div id="readability-content">
<div>
<ol><li>first item</li><li>second item</li></ol>
</p>
</div>
</div>
`, TEST_OPTIONS
)
const text = ssml[0].textItems.join('').trim()
expect(text).to.equal(
`<p><s>first item</s><s>second item</s></p>`.trim()
)
})
})
// For local testing:
// describe('readability test files', () => {
// it('should convert Html to SSML without throwing', async () => {