mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
refactor(WebSocketManager): passing in strategy (#9122)
* refactor(WebSocketManager): passing in strategy * chore: update tests * chore: requested nits --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -163,6 +163,7 @@ test('spawn, connect, send a message, session info, and destroy', async () => {
|
||||
shardIds: [0, 1],
|
||||
retrieveSessionInfo: mockRetrieveSessionInfo,
|
||||
updateSessionInfo: mockUpdateSessionInfo,
|
||||
buildStrategy: (manager) => new WorkerShardingStrategy(manager, { shardsPerWorker: 'all' }),
|
||||
});
|
||||
|
||||
const managerEmitSpy = vi.spyOn(manager, 'emit');
|
||||
@@ -191,9 +192,6 @@ test('spawn, connect, send a message, session info, and destroy', async () => {
|
||||
},
|
||||
}));
|
||||
|
||||
const strategy = new WorkerShardingStrategy(manager, { shardsPerWorker: 'all' });
|
||||
manager.setStrategy(strategy);
|
||||
|
||||
await manager.connect();
|
||||
expect(mockConstructor).toHaveBeenCalledWith(
|
||||
expect.stringContaining('defaultWorker.js'),
|
||||
|
||||
@@ -177,14 +177,21 @@ test('strategies', async () => {
|
||||
public destroy = vi.fn();
|
||||
|
||||
public send = vi.fn();
|
||||
|
||||
public fetchStatus = vi.fn();
|
||||
}
|
||||
|
||||
const strategy = new MockStrategy();
|
||||
|
||||
const rest = new REST().setAgent(mockAgent).setToken('A-Very-Fake-Token');
|
||||
const shardIds = [0, 1, 2];
|
||||
const manager = new WebSocketManager({ token: 'A-Very-Fake-Token', intents: 0, rest, shardIds });
|
||||
|
||||
const strategy = new MockStrategy();
|
||||
manager.setStrategy(strategy);
|
||||
const manager = new WebSocketManager({
|
||||
token: 'A-Very-Fake-Token',
|
||||
intents: 0,
|
||||
rest,
|
||||
shardIds,
|
||||
buildStrategy: () => strategy,
|
||||
});
|
||||
|
||||
const data: APIGatewayBotInfo = {
|
||||
shards: 1,
|
||||
|
||||
Reference in New Issue
Block a user