refactor: use eslint-config-neon for packages. (#8579)

Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
Suneet Tipirneni
2022-09-01 14:50:16 -04:00
committed by GitHub
parent 4bdb0593ae
commit edadb9fe5d
219 changed files with 2608 additions and 2053 deletions

View File

@@ -1,14 +1,17 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Buffer } from 'node:buffer';
import process from 'node:process';
import { PassThrough, Readable } from 'node:stream';
import { opus, VolumeTransformer } from 'prism-media';
import { SILENCE_FRAME } from '../src/audio/AudioPlayer';
import { AudioResource, createAudioResource, NO_CONSTRAINT, VOLUME_CONSTRAINT } from '../src/audio/AudioResource';
import { Edge, findPipeline as _findPipeline, StreamType, TransformerType } from '../src/audio/TransformerGraph';
import { findPipeline as _findPipeline, StreamType, TransformerType, type Edge } from '../src/audio/TransformerGraph';
jest.mock('prism-media');
jest.mock('../src/audio/TransformerGraph');
function wait() {
async function wait() {
// eslint-disable-next-line no-promise-executor-return
return new Promise((resolve) => process.nextTick(resolve));
}
@@ -16,12 +19,14 @@ async function started(resource: AudioResource) {
while (!resource.started) {
await wait();
}
return resource;
}
const findPipeline = _findPipeline as unknown as jest.MockedFunction<typeof _findPipeline>;
beforeAll(() => {
// @ts-expect-error no type
findPipeline.mockImplementation((from: StreamType, constraint: (path: Edge[]) => boolean) => {
const base = [
{
@@ -38,6 +43,7 @@ beforeAll(() => {
type: TransformerType.InlineVolume,
});
}
return base as any[];
});
});
@@ -113,11 +119,12 @@ describe('createAudioResource', () => {
await started(resource);
expect(resource.readable).toEqual(true);
expect(resource.read()).toEqual(Buffer.from([1]));
for (let i = 0; i < 5; i++) {
for (let index = 0; index < 5; index++) {
await wait();
expect(resource.readable).toEqual(true);
expect(resource.read()).toEqual(SILENCE_FRAME);
}
await wait();
expect(resource.readable).toEqual(false);
expect(resource.read()).toEqual(null);