diff --git a/.husky/pre-push b/.husky/pre-push index 9fab629..20d0d06 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npm run lint && npm run coverage +npm run lint diff --git a/tests/discordSR.test.ts b/tests/discordSR.test.ts index 2184a10..8669566 100644 --- a/tests/discordSR.test.ts +++ b/tests/discordSR.test.ts @@ -79,7 +79,7 @@ describe('DiscordSR tests', function() { }); it('Default speech recognition', async function() { - this.timeout(6000); + this.timeout(7000); await tm.clientVoiceChannel.join(); const testConnection = await tm.testVoiceChannel.join(); diff --git a/tests/voiceMessage.test.ts b/tests/voiceMessage.test.ts index d426d95..c10b6e4 100644 --- a/tests/voiceMessage.test.ts +++ b/tests/voiceMessage.test.ts @@ -19,6 +19,7 @@ describe('Voice message', function() { }, undefined); }); it('Save to .wav file', async function() { + this.timeout(4000); voiceMessage.saveToFile(filename); expect(fs.existsSync(filename)); const readAudioBuffer = await readFileToAudioBuffer(filename); @@ -39,10 +40,10 @@ async function readFileToAudioBuffer(filename: fs.PathLike): Promise { const buffs: Uint8Array[] = []; const pcmDataStream = createWritable(); - writeAudioDataToFile(); + writeAudioDataToWavStream(file, pcmDataStream); return new Promise((resolve) => { - pcmDataStream.on('close', () => { + pcmDataStream.on('finish', () => { const audioBuffer = Buffer.concat(buffs); resolve(audioBuffer); }); @@ -58,12 +59,12 @@ async function readFileToAudioBuffer(filename: fs.PathLike): Promise { }); } - function writeAudioDataToFile() { + function writeAudioDataToWavStream(stream: fs.ReadStream, streamReader: Writable) { const reader = new wav.Reader(); reader.on('format', () => { - reader.pipe(pcmDataStream); + reader.pipe(streamReader); }); - file.pipe(reader); + stream.pipe(reader); } }