Skip to content

Commit

Permalink
Update test to ignore priming
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Aug 6, 2019
1 parent 265e236 commit b530818
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion __tests__/setup/web/mockWebSpeech.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ const SPEECH_SYNTHESIS_VOICES = [
];

class SpeechSynthesis extends EventTarget {
constructor() {
super();

this.ignoreFirstUtteranceIfEmpty = true;
}

getVoices() {
return SPEECH_SYNTHESIS_VOICES;
}
Expand All @@ -238,7 +244,13 @@ class SpeechSynthesis extends EventTarget {
}

speak(utterance) {
speechSynthesisBroker.produce(utterance);
// We prime the speech engine by sending an empty utterance on start.
// We should ignore the first utterance if it is empty.
if (!this.ignoreFirstUtteranceIfEmpty || utterance.text) {
speechSynthesisBroker.produce(utterance);
}

this.ignoreFirstUtteranceIfEmpty = false;
}
}

Expand Down

0 comments on commit b530818

Please sign in to comment.