File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,8 +120,8 @@ To mock the package's methods and components using the default mock configuratio
120120
121121- Copy the following code into that file:
122122
123- ``` ts
124- export * from ' @mhpdev/react-native-speech/jest' ;
123+ ``` js
124+ module . exports = require ( ' @mhpdev/react-native-speech/jest' ) ;
125125 ```
126126
127127## Contributing
Original file line number Diff line number Diff line change 1+ const mockFn = ( ...args ) => {
2+ return undefined ;
3+ } ;
4+
5+ const mockPromise = ( ...args ) => Promise . resolve ( undefined ) ;
6+ const mockPromiseBool = ( ...args ) => Promise . resolve ( false ) ;
7+ const mockPromiseArr = ( ...args ) => Promise . resolve ( [ ] ) ;
8+
9+ const { fn : jestFn } = require ( 'jest-mock' ) ;
10+ const eventSub = { remove : jestFn ( ) } ;
11+ const eventMock = jestFn ( ( ) => eventSub ) ;
12+
13+ class Speech {
14+ static reset = mockFn ;
15+ static stop = mockPromise ;
16+ static initialize = mockFn ;
17+ static speak = mockPromise ;
18+ static pause = mockPromiseBool ;
19+ static resume = mockPromiseBool ;
20+ static isSpeaking = mockPromiseBool ;
21+ static speakWithOptions = mockPromise ;
22+ static getAvailableVoices = mockPromiseArr ;
23+ static onError = eventMock ;
24+ static onStart = eventMock ;
25+ static onFinish = eventMock ;
26+ static onPause = eventMock ;
27+ static onResume = eventMock ;
28+ static onStopped = eventMock ;
29+ static onProgress = eventMock ;
30+ }
31+
32+ const HighlightedText = jestFn ( function HighlightedText ( ) {
33+ return null ;
34+ } ) ;
35+
36+ module . exports = {
37+ __esModule : true ,
38+ default : Speech ,
39+ HighlightedText,
40+ } ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments