52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
|
|
/* eslint-disable import/first */
|
||
|
|
|
||
|
|
import { Platform } from 'react-native';
|
||
|
|
|
||
|
|
jest.mock('expo-audio', () => ({
|
||
|
|
AudioModule: { AudioRecorder: jest.fn() },
|
||
|
|
AudioQuality: {
|
||
|
|
HIGH: 'high',
|
||
|
|
},
|
||
|
|
IOSOutputFormat: {
|
||
|
|
MPEG4AAC: 'aac',
|
||
|
|
},
|
||
|
|
}));
|
||
|
|
|
||
|
|
import {
|
||
|
|
buildVoiceRecordingOptions,
|
||
|
|
VOICE_RECORDING_OPTIONS,
|
||
|
|
} from '@/features/voice/recorder';
|
||
|
|
|
||
|
|
describe('buildVoiceRecordingOptions', () => {
|
||
|
|
test('uses 16 kHz mono m4a recording options for Tencent-compatible speech capture', () => {
|
||
|
|
const passedOptions = buildVoiceRecordingOptions();
|
||
|
|
|
||
|
|
expect(passedOptions).toEqual(
|
||
|
|
expect.objectContaining({
|
||
|
|
extension: '.m4a',
|
||
|
|
sampleRate: 16_000,
|
||
|
|
numberOfChannels: 1,
|
||
|
|
bitRate: 32_000,
|
||
|
|
}),
|
||
|
|
);
|
||
|
|
|
||
|
|
if (Platform.OS === 'ios') {
|
||
|
|
expect(passedOptions).toEqual(
|
||
|
|
expect.objectContaining({
|
||
|
|
outputFormat: VOICE_RECORDING_OPTIONS.ios.outputFormat,
|
||
|
|
audioQuality: VOICE_RECORDING_OPTIONS.ios.audioQuality,
|
||
|
|
}),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (Platform.OS === 'android') {
|
||
|
|
expect(passedOptions).toEqual(
|
||
|
|
expect.objectContaining({
|
||
|
|
outputFormat: VOICE_RECORDING_OPTIONS.android.outputFormat,
|
||
|
|
audioEncoder: VOICE_RECORDING_OPTIONS.android.audioEncoder,
|
||
|
|
}),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|