diff --git a/packages/text-to-speech/mocha-config.json b/packages/text-to-speech/mocha-config.json index 5a2631f42..8e24eb08b 100644 --- a/packages/text-to-speech/mocha-config.json +++ b/packages/text-to-speech/mocha-config.json @@ -1,4 +1,5 @@ { "extension": ["ts"], - "spec": "test/**/*.test.ts" + "spec": "test/**/*.test.ts", + "timeout": 10000 } diff --git a/packages/text-to-speech/test/htmlToSsml.test.ts b/packages/text-to-speech/test/htmlToSsml.test.ts index 88c23d386..62063c3d2 100644 --- a/packages/text-to-speech/test/htmlToSsml.test.ts +++ b/packages/text-to-speech/test/htmlToSsml.test.ts @@ -350,6 +350,41 @@ describe('convert HTML to Speech file', () => { options: TEST_OPTIONS, }) expect(speechFile.utterances).to.have.lengthOf(2) - expect(speechFile.utterances[1].text).to.eql('McMeekin makes an extended case that Stalin was preparing to attack Nazi Germany when Hitler attacked him, that the two dictators were basically in a race to see who could mobilize to betray the other first — and that the initial Soviet debacle in 1941 happened in part because Stalin was also pushing his military toward an offensive alignment, and they were caught in a "mid-mobilization limbo."') + expect(speechFile.utterances[1].text).to.eql( + 'McMeekin makes an extended case that Stalin was preparing to attack Nazi Germany when Hitler attacked him, that the two dictators were basically in a race to see who could mobilize to betray the other first — and that the initial Soviet debacle in 1941 happened in part because Stalin was also pushing his military toward an offensive alignment, and they were caught in a "mid-mobilization limbo."' + ) + }) + + it('skip unwanted elements', () => { + const html = `
+

This is a test.

+ + + +
test
+
` + + const speechFile = htmlToSpeechFile({ + content: html, + options: TEST_OPTIONS, + }) + expect(speechFile.utterances).to.have.lengthOf(1) + expect(speechFile.utterances[0].text).to.eql('This is a test.') + }) + + it('filters out utterances with only punctuation or whitespace', () => { + const html = `
+

This is a test.

+

.

+

+
` + + const speechFile = htmlToSpeechFile({ + content: html, + options: TEST_OPTIONS, + }) + + expect(speechFile.utterances).to.have.lengthOf(1) + expect(speechFile.utterances[0].text).to.eql('This is a test.') }) }) diff --git a/packages/text-to-speech/tsconfig.json b/packages/text-to-speech/tsconfig.json index 5b6ea3e00..7634a8d53 100644 --- a/packages/text-to-speech/tsconfig.json +++ b/packages/text-to-speech/tsconfig.json @@ -6,5 +6,5 @@ // Generate d.ts files "declaration": true }, - "include": ["src"] + "include": ["src", "test"] }