From 0236f2b67589a922f12daa1d7ac434360e729b36 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 30 Aug 2022 12:21:10 +0800 Subject: [PATCH] More SSML test cases --- .../text-to-speech/test/htmlToSsml.test.ts | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/packages/text-to-speech/test/htmlToSsml.test.ts b/packages/text-to-speech/test/htmlToSsml.test.ts index b7e335341..55d058476 100644 --- a/packages/text-to-speech/test/htmlToSsml.test.ts +++ b/packages/text-to-speech/test/htmlToSsml.test.ts @@ -29,6 +29,36 @@ describe('htmlToSsml', () => { ) }) }) + describe('escaping', () => { + it('should convert   to spaces', async () => { + const ssml = htmlToSsml(` +
+
+

some  space

+
+
+ `, TEST_OPTIONS + ) + const text = ssml[0].textItems.join('').trim() + expect(text).to.equal( + `

some space

` + ) + }) + it('should remove emojis', async () => { + const ssml = htmlToSsml(` +
+
+

no emoji here 🙏🙏

+
+
+ `, TEST_OPTIONS + ) + const text = ssml[0].textItems.join('').trim() + expect(text).to.equal( + `

no emoji here

` + ) + }) + }) 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

and ', async () => { + const ssml = htmlToSsml(` +

+
+
  • first item
  • second item
+

+
+
+ `, TEST_OPTIONS + ) + const text = ssml[0].textItems.join('').trim() + expect(text).to.equal( + `

first itemsecond item

`.trim() + ) + }) + it('should convert a ol to

and ', async () => { + const ssml = htmlToSsml(` +

+
+
  1. first item
  2. second item
+

+
+
+ `, TEST_OPTIONS + ) + const text = ssml[0].textItems.join('').trim() + expect(text).to.equal( + `

first itemsecond item

`.trim() + ) + }) + }) // For local testing: // describe('readability test files', () => { // it('should convert Html to SSML without throwing', async () => {