From 0e8109168363bd35675be42c6f298f2f59847a5a Mon Sep 17 00:00:00 2001 From: Jhen Date: Tue, 7 Nov 2023 09:54:57 +0800 Subject: [PATCH] fix: tests --- docs/API/README.md | 36 +++++++++---------- docs/API/classes/WhisperContext.md | 14 ++++---- docs/API/enums/AudioSessionCategoryIos.md | 12 +++---- .../enums/AudioSessionCategoryOptionIos.md | 14 ++++---- docs/API/enums/AudioSessionModeIos.md | 16 ++++----- jest/mock.js | 2 +- .../__snapshots__/index.test.ts.snap | 12 ++----- src/__tests__/index.test.ts | 2 +- 8 files changed, 51 insertions(+), 57 deletions(-) diff --git a/docs/API/README.md b/docs/API/README.md index 841a0c4..99bcd01 100644 --- a/docs/API/README.md +++ b/docs/API/README.md @@ -58,7 +58,7 @@ whisper.rn #### Defined in -[index.ts:76](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L76) +[index.ts:76](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L76) ___ @@ -80,7 +80,7 @@ ___ #### Defined in -[index.ts:438](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L438) +[index.ts:438](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L438) ___ @@ -90,7 +90,7 @@ ___ #### Defined in -[index.ts:59](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L59) +[index.ts:59](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L59) ___ @@ -108,7 +108,7 @@ ___ #### Defined in -[index.ts:52](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L52) +[index.ts:52](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L52) ___ @@ -127,7 +127,7 @@ ___ #### Defined in -[index.ts:45](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L45) +[index.ts:45](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L45) ___ @@ -157,7 +157,7 @@ ___ #### Defined in -[NativeRNWhisper.ts:5](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/NativeRNWhisper.ts#L5) +[NativeRNWhisper.ts:5](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/NativeRNWhisper.ts#L5) ___ @@ -175,7 +175,7 @@ ___ #### Defined in -[index.ts:70](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L70) +[index.ts:70](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L70) ___ @@ -200,7 +200,7 @@ ___ #### Defined in -[index.ts:133](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L133) +[index.ts:133](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L133) ___ @@ -218,7 +218,7 @@ ___ #### Defined in -[index.ts:166](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L166) +[index.ts:166](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L166) ___ @@ -242,7 +242,7 @@ ___ #### Defined in -[index.ts:153](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L153) +[index.ts:153](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L153) ___ @@ -252,7 +252,7 @@ ___ #### Defined in -[index.ts:84](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L84) +[index.ts:84](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L84) ___ @@ -270,7 +270,7 @@ ___ #### Defined in -[NativeRNWhisper.ts:37](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/NativeRNWhisper.ts#L37) +[NativeRNWhisper.ts:37](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/NativeRNWhisper.ts#L37) ## Variables @@ -295,7 +295,7 @@ AudioSession Utility, iOS only. #### Defined in -[AudioSessionIos.ts:50](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L50) +[AudioSessionIos.ts:50](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L50) ___ @@ -307,7 +307,7 @@ Is allow fallback to CPU if load CoreML model failed #### Defined in -[index.ts:540](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L540) +[index.ts:540](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L540) ___ @@ -319,7 +319,7 @@ Is use CoreML models on iOS #### Defined in -[index.ts:537](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L537) +[index.ts:537](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L537) ___ @@ -331,7 +331,7 @@ Current version of whisper.cpp #### Defined in -[index.ts:532](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L532) +[index.ts:532](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L532) ## Functions @@ -351,7 +351,7 @@ Current version of whisper.cpp #### Defined in -[index.ts:464](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L464) +[index.ts:464](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L464) ___ @@ -365,4 +365,4 @@ ___ #### Defined in -[index.ts:527](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L527) +[index.ts:527](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L527) diff --git a/docs/API/classes/WhisperContext.md b/docs/API/classes/WhisperContext.md index 2c8dd72..feb05a9 100644 --- a/docs/API/classes/WhisperContext.md +++ b/docs/API/classes/WhisperContext.md @@ -34,7 +34,7 @@ #### Defined in -[index.ts:190](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L190) +[index.ts:190](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L190) ## Properties @@ -44,7 +44,7 @@ #### Defined in -[index.ts:186](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L186) +[index.ts:186](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L186) ___ @@ -54,7 +54,7 @@ ___ #### Defined in -[index.ts:184](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L184) +[index.ts:184](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L184) ___ @@ -64,7 +64,7 @@ ___ #### Defined in -[index.ts:188](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L188) +[index.ts:188](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L188) ## Methods @@ -78,7 +78,7 @@ ___ #### Defined in -[index.ts:433](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L433) +[index.ts:433](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L433) ___ @@ -106,7 +106,7 @@ Transcribe audio file #### Defined in -[index.ts:201](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L201) +[index.ts:201](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L201) ___ @@ -128,4 +128,4 @@ Transcribe the microphone audio stream, the microphone user permission is requir #### Defined in -[index.ts:297](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/index.ts#L297) +[index.ts:297](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/index.ts#L297) diff --git a/docs/API/enums/AudioSessionCategoryIos.md b/docs/API/enums/AudioSessionCategoryIos.md index 99d59b4..002613c 100644 --- a/docs/API/enums/AudioSessionCategoryIos.md +++ b/docs/API/enums/AudioSessionCategoryIos.md @@ -25,7 +25,7 @@ https://developer.apple.com/documentation/avfaudio/avaudiosessioncategory?langua #### Defined in -[AudioSessionIos.ts:8](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L8) +[AudioSessionIos.ts:8](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L8) ___ @@ -35,7 +35,7 @@ ___ #### Defined in -[AudioSessionIos.ts:13](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L13) +[AudioSessionIos.ts:13](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L13) ___ @@ -45,7 +45,7 @@ ___ #### Defined in -[AudioSessionIos.ts:12](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L12) +[AudioSessionIos.ts:12](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L12) ___ @@ -55,7 +55,7 @@ ___ #### Defined in -[AudioSessionIos.ts:10](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L10) +[AudioSessionIos.ts:10](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L10) ___ @@ -65,7 +65,7 @@ ___ #### Defined in -[AudioSessionIos.ts:11](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L11) +[AudioSessionIos.ts:11](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L11) ___ @@ -75,4 +75,4 @@ ___ #### Defined in -[AudioSessionIos.ts:9](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L9) +[AudioSessionIos.ts:9](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L9) diff --git a/docs/API/enums/AudioSessionCategoryOptionIos.md b/docs/API/enums/AudioSessionCategoryOptionIos.md index e92b877..dab973c 100644 --- a/docs/API/enums/AudioSessionCategoryOptionIos.md +++ b/docs/API/enums/AudioSessionCategoryOptionIos.md @@ -26,7 +26,7 @@ https://developer.apple.com/documentation/avfaudio/avaudiosessioncategoryoptions #### Defined in -[AudioSessionIos.ts:25](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L25) +[AudioSessionIos.ts:25](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L25) ___ @@ -36,7 +36,7 @@ ___ #### Defined in -[AudioSessionIos.ts:23](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L23) +[AudioSessionIos.ts:23](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L23) ___ @@ -46,7 +46,7 @@ ___ #### Defined in -[AudioSessionIos.ts:24](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L24) +[AudioSessionIos.ts:24](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L24) ___ @@ -56,7 +56,7 @@ ___ #### Defined in -[AudioSessionIos.ts:26](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L26) +[AudioSessionIos.ts:26](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L26) ___ @@ -66,7 +66,7 @@ ___ #### Defined in -[AudioSessionIos.ts:21](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L21) +[AudioSessionIos.ts:21](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L21) ___ @@ -76,7 +76,7 @@ ___ #### Defined in -[AudioSessionIos.ts:22](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L22) +[AudioSessionIos.ts:22](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L22) ___ @@ -86,4 +86,4 @@ ___ #### Defined in -[AudioSessionIos.ts:20](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L20) +[AudioSessionIos.ts:20](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L20) diff --git a/docs/API/enums/AudioSessionModeIos.md b/docs/API/enums/AudioSessionModeIos.md index 7771ddb..4b1f9cf 100644 --- a/docs/API/enums/AudioSessionModeIos.md +++ b/docs/API/enums/AudioSessionModeIos.md @@ -27,7 +27,7 @@ https://developer.apple.com/documentation/avfaudio/avaudiosessionmode?language=o #### Defined in -[AudioSessionIos.ts:33](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L33) +[AudioSessionIos.ts:33](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L33) ___ @@ -37,7 +37,7 @@ ___ #### Defined in -[AudioSessionIos.ts:36](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L36) +[AudioSessionIos.ts:36](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L36) ___ @@ -47,7 +47,7 @@ ___ #### Defined in -[AudioSessionIos.ts:38](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L38) +[AudioSessionIos.ts:38](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L38) ___ @@ -57,7 +57,7 @@ ___ #### Defined in -[AudioSessionIos.ts:39](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L39) +[AudioSessionIos.ts:39](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L39) ___ @@ -67,7 +67,7 @@ ___ #### Defined in -[AudioSessionIos.ts:40](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L40) +[AudioSessionIos.ts:40](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L40) ___ @@ -77,7 +77,7 @@ ___ #### Defined in -[AudioSessionIos.ts:35](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L35) +[AudioSessionIos.ts:35](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L35) ___ @@ -87,7 +87,7 @@ ___ #### Defined in -[AudioSessionIos.ts:37](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L37) +[AudioSessionIos.ts:37](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L37) ___ @@ -97,4 +97,4 @@ ___ #### Defined in -[AudioSessionIos.ts:34](https://github.com/mybigday/whisper.rn/blob/eed3c2b/src/AudioSessionIos.ts#L34) +[AudioSessionIos.ts:34](https://github.com/mybigday/whisper.rn/blob/e6c445e/src/AudioSessionIos.ts#L34) diff --git a/jest/mock.js b/jest/mock.js index 3e177f5..dca094a 100644 --- a/jest/mock.js +++ b/jest/mock.js @@ -2,7 +2,7 @@ const { NativeModules, DeviceEventEmitter } = require('react-native') if (!NativeModules.RNWhisper) { NativeModules.RNWhisper = { - initContext: jest.fn(() => Promise.resolve({ id: 1 })), + initContext: jest.fn(() => Promise.resolve({ contextId: 1 })), transcribeFile: jest.fn(() => Promise.resolve({ result: ' Test', segments: [{ text: ' Test', t0: 0, t1: 33 }], diff --git a/src/__tests__/__snapshots__/index.test.ts.snap b/src/__tests__/__snapshots__/index.test.ts.snap index 1c3c579..dc87a8a 100644 --- a/src/__tests__/__snapshots__/index.test.ts.snap +++ b/src/__tests__/__snapshots__/index.test.ts.snap @@ -3,9 +3,7 @@ exports[`Mock 1`] = ` [ { - "contextId": { - "id": 1, - }, + "contextId": 1, "data": { "result": " Test", "segments": [ @@ -22,9 +20,7 @@ exports[`Mock 1`] = ` "recordingTime": 1000, }, { - "contextId": { - "id": 1, - }, + "contextId": 1, "data": { "result": " Test", "segments": [ @@ -41,9 +37,7 @@ exports[`Mock 1`] = ` "recordingTime": 2000, }, { - "contextId": { - "id": 1, - }, + "contextId": 1, "data": { "result": " Test", "segments": [ diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 2ee4519..f343720 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -8,7 +8,7 @@ test('Mock', async () => { const context = await initWhisper({ filePath: 'test.bin', }) - expect(context.id).toEqual({ id: 1 }) + expect(context.id).toBe(1) const { promise } = context.transcribe('test.wav') expect(await promise).toEqual({ isAborted: false,