|
| 1 | +import {createElement} from 'react'; |
| 2 | +import type { |
| 3 | + VoiceProps, |
| 4 | + EventProps, |
| 5 | + VoiceOptions, |
| 6 | + ProgressEventProps, |
| 7 | +} from '../src/NativeSpeech'; |
| 8 | +import type { |
| 9 | + HighlightedTextProps, |
| 10 | + HighlightedSegmentArgs, |
| 11 | + HighlightedSegmentProps, |
| 12 | +} from '../src/components/types'; |
| 13 | + |
| 14 | +class SpeechMock { |
| 15 | + static reset = jest.fn<void, []>(); |
| 16 | + static stop = jest.fn<Promise<void>, []>(); |
| 17 | + static pause = jest.fn<Promise<boolean>, []>(); |
| 18 | + static resume = jest.fn<Promise<boolean>, []>(); |
| 19 | + static speak = jest.fn<Promise<void>, [string]>(); |
| 20 | + static isSpeaking = jest.fn<Promise<boolean>, []>(); |
| 21 | + static initialize = jest.fn<void, [VoiceOptions]>(); |
| 22 | + static getAvailableVoices = jest.fn<Promise<VoiceProps[]>, [string?]>(); |
| 23 | + static speakWithOptions = jest.fn<Promise<void>, [string, VoiceOptions]>(); |
| 24 | + static onError = jest.fn(); |
| 25 | + static onStart = jest.fn(); |
| 26 | + static onFinish = jest.fn(); |
| 27 | + static onPause = jest.fn(); |
| 28 | + static onResume = jest.fn(); |
| 29 | + static onStopped = jest.fn(); |
| 30 | + static onProgress = jest.fn(); |
| 31 | +} |
| 32 | + |
| 33 | +export const HighlightedText: React.FC<HighlightedTextProps> = props => { |
| 34 | + return createElement('HighlightedText', props, props.text); |
| 35 | +}; |
| 36 | + |
| 37 | +export default SpeechMock; |
| 38 | +export type { |
| 39 | + VoiceProps, |
| 40 | + EventProps, |
| 41 | + VoiceOptions, |
| 42 | + ProgressEventProps, |
| 43 | + HighlightedTextProps, |
| 44 | + HighlightedSegmentArgs, |
| 45 | + HighlightedSegmentProps, |
| 46 | +}; |
0 commit comments