Skip to content

Commit

Permalink
test(voice): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Jan 11, 2022
1 parent db25f52 commit 62c74b8
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged && yarn lint:fix
yarn format
3 changes: 0 additions & 3 deletions .lintstagedrc.json

This file was deleted.

8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"build": "turbo run build",
"test": "turbo run test",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
"format": "turbo run format",
"fmt": "turbo run format",
"postinstall": "is-ci || husky install",
Expand Down Expand Up @@ -44,7 +43,6 @@
"@favware/npm-deprecate": "^1.0.4",
"conventional-changelog-cli": "^2.2.2",
"husky": "^7.0.4",
"lint-staged": "^12.1.7",
"prettier": "^2.5.1",
"turbo": "1.0.24"
},
Expand Down Expand Up @@ -80,12 +78,6 @@
],
"outputs": []
},
"lint:fix": {
"dependsOn": [
"^build"
],
"outputs": []
},
"format": {
"outputs": []
},
Expand Down
5 changes: 1 addition & 4 deletions packages/rest/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

// Emit
"outDir": "./dist",
"sourceRoot": "./",

// Projects
"composite": true
"sourceRoot": "./"
},
"include": ["src/**/*.ts"]
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/dot-notation */
import { AudioResource } from '../../audio/AudioResource';
import { createAudioPlayer, AudioPlayerStatus, AudioPlayer, SILENCE_FRAME } from '../AudioPlayer';
import { AudioResource } from '../src/audio/AudioResource';
import { createAudioPlayer, AudioPlayerStatus, AudioPlayer, SILENCE_FRAME } from '../src/audio/AudioPlayer';
import { Readable } from 'node:stream';
import { addAudioPlayer, deleteAudioPlayer } from '../../DataStore';
import { NoSubscriberBehavior } from '../..';
import { VoiceConnection, VoiceConnectionStatus } from '../../VoiceConnection';
import { addAudioPlayer, deleteAudioPlayer } from '../src/DataStore';
import { NoSubscriberBehavior } from '../src';
import { VoiceConnection, VoiceConnectionStatus } from '../src/VoiceConnection';
import { once } from 'node:events';
import { AudioPlayerError } from '../AudioPlayerError';
import { AudioPlayerError } from '../src/audio/AudioPlayerError';

jest.mock('../../DataStore');
jest.mock('../../VoiceConnection');
jest.mock('../AudioPlayerError');
jest.mock('../src/DataStore');
jest.mock('../src/VoiceConnection');
jest.mock('../src/audio/AudioPlayerError');

const addAudioPlayerMock = addAudioPlayer as unknown as jest.Mock<typeof addAudioPlayer>;
const deleteAudioPlayerMock = deleteAudioPlayer as unknown as jest.Mock<typeof deleteAudioPlayer>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SILENCE_FRAME } from '../../audio/AudioPlayer';
import { AudioReceiveStream, EndBehaviorType } from '../AudioReceiveStream';
import { SILENCE_FRAME } from '../src/audio/AudioPlayer';
import { AudioReceiveStream, EndBehaviorType } from '../src/receive/AudioReceiveStream';

const DUMMY_BUFFER = Buffer.allocUnsafe(16);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { opus, VolumeTransformer } from 'prism-media';
import { PassThrough, Readable } from 'node:stream';
import { SILENCE_FRAME } from '../AudioPlayer';
import { AudioResource, createAudioResource, NO_CONSTRAINT, VOLUME_CONSTRAINT } from '../AudioResource';
import { Edge, findPipeline as _findPipeline, StreamType, TransformerType } from '../TransformerGraph';
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';

jest.mock('prism-media');
jest.mock('../TransformerGraph');
jest.mock('../src/audio/TransformerGraph');

function wait() {
return new Promise((resolve) => process.nextTick(resolve));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import EventEmitter, { once } from 'node:events';
import { SSRCMap, VoiceUserData } from '../SSRCMap';
import { SSRCMap, VoiceUserData } from '../src/receive/SSRCMap';

function onceOrThrow<T extends EventEmitter>(target: T, event: string, after: number) {
return new Promise((resolve, reject) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { methods } from '../Secretbox';
import { methods } from '../src/util/Secretbox';

jest.mock('tweetnacl');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { noop } from '../../util/util';
import { SpeakingMap } from '../SpeakingMap';
import { noop } from '../src/util/util';
import { SpeakingMap } from '../src/receive/SpeakingMap';

jest.useFakeTimers();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Edge, findPipeline, StreamType, TransformerType } from '../TransformerGraph';
import { Edge, findPipeline, StreamType, TransformerType } from '../src/audio/TransformerGraph';

const noConstraint = () => true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/dot-notation */
import { VoiceReceiver } from '../VoiceReceiver';
import { VoiceConnection as _VoiceConnection, VoiceConnectionStatus } from '../../VoiceConnection';
import { RTP_PACKET_DESKTOP, RTP_PACKET_CHROME, RTP_PACKET_ANDROID } from './fixtures/rtp';
import { VoiceReceiver } from '../src/receive/VoiceReceiver';
import { VoiceConnection as _VoiceConnection, VoiceConnectionStatus } from '../src/VoiceConnection';
import { RTP_PACKET_DESKTOP, RTP_PACKET_CHROME, RTP_PACKET_ANDROID } from '../__mocks__/rtp';
import { once } from 'node:events';
import { VoiceOpcodes } from 'discord-api-types/voice/v4';
import { methods } from '../../util/Secretbox';
import { methods } from '../src/util/Secretbox';

jest.mock('../../VoiceConnection');
jest.mock('../SSRCMap');
jest.mock('../src/VoiceConnection');
jest.mock('../src/receive/SSRCMap');

const openSpy = jest.spyOn(methods, 'open');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { createSocket as _createSocket } from 'node:dgram';
import EventEmitter, { once } from 'node:events';
import { VoiceUDPSocket } from '../VoiceUDPSocket';
import { VoiceUDPSocket } from '../src/networking/VoiceUDPSocket';

jest.mock('node:dgram');
jest.useFakeTimers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { VoiceOpcodes } from 'discord-api-types/voice/v4';
import EventEmitter, { once } from 'node:events';
import WS from 'jest-websocket-mock';
import { VoiceWebSocket } from '../VoiceWebSocket';
import { VoiceWebSocket } from '../src/networking/VoiceWebSocket';

beforeEach(() => {
WS.clean();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { abortAfter } from '../abortAfter';
import { abortAfter } from '../src/util/abortAfter';

jest.useFakeTimers();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { demuxProbe } from '../demuxProbe';
import { demuxProbe } from '../src/util/demuxProbe';
import { opus as _opus } from 'prism-media';
import { Readable } from 'node:stream';
import { StreamType } from '../../audio';
import { StreamType } from '../src/audio';
import EventEmitter, { once } from 'node:events';

jest.mock('prism-media');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import EventEmitter from 'node:events';
import { VoiceConnection, VoiceConnectionStatus } from '../../VoiceConnection';
import { entersState } from '../entersState';
import { VoiceConnection, VoiceConnectionStatus } from '../src/VoiceConnection';
import { entersState } from '../src/util/entersState';

function createFakeVoiceConnection(status = VoiceConnectionStatus.Signalling) {
const vc = new EventEmitter() as any;
Expand Down
Loading

0 comments on commit 62c74b8

Please sign in to comment.