mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
tests(ws): fix tests (#9520)
This commit is contained in:
@@ -146,9 +146,9 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
mockConstructor.mockRestore();
|
mockConstructor.mockClear();
|
||||||
mockSend.mockRestore();
|
mockSend.mockClear();
|
||||||
mockTerminate.mockRestore();
|
mockTerminate.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('spawn, connect, send a message, session info, and destroy', async () => {
|
test('spawn, connect, send a message, session info, and destroy', async () => {
|
||||||
|
|||||||
@@ -54,13 +54,13 @@ test('fetch gateway information', async () => {
|
|||||||
expect(initial).toEqual(data);
|
expect(initial).toEqual(data);
|
||||||
expect(fetch).toHaveBeenCalledOnce();
|
expect(fetch).toHaveBeenCalledOnce();
|
||||||
|
|
||||||
fetch.mockRestore();
|
fetch.mockClear();
|
||||||
|
|
||||||
const cached = await manager.fetchGatewayInformation();
|
const cached = await manager.fetchGatewayInformation();
|
||||||
expect(cached).toEqual(data);
|
expect(cached).toEqual(data);
|
||||||
expect(fetch).not.toHaveBeenCalled();
|
expect(fetch).not.toHaveBeenCalled();
|
||||||
|
|
||||||
fetch.mockRestore();
|
fetch.mockClear();
|
||||||
mockPool
|
mockPool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: '/api/v10/gateway/bot',
|
path: '/api/v10/gateway/bot',
|
||||||
@@ -72,7 +72,7 @@ test('fetch gateway information', async () => {
|
|||||||
expect(forced).toEqual(data);
|
expect(forced).toEqual(data);
|
||||||
expect(fetch).toHaveBeenCalledOnce();
|
expect(fetch).toHaveBeenCalledOnce();
|
||||||
|
|
||||||
fetch.mockRestore();
|
fetch.mockClear();
|
||||||
mockPool
|
mockPool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: '/api/v10/gateway/bot',
|
path: '/api/v10/gateway/bot',
|
||||||
@@ -146,7 +146,7 @@ test('update shard count', async () => {
|
|||||||
expect(await manager.getShardCount()).toBe(2);
|
expect(await manager.getShardCount()).toBe(2);
|
||||||
expect(fetch).not.toHaveBeenCalled();
|
expect(fetch).not.toHaveBeenCalled();
|
||||||
|
|
||||||
fetch.mockRestore();
|
fetch.mockClear();
|
||||||
mockPool
|
mockPool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: '/api/v10/gateway/bot',
|
path: '/api/v10/gateway/bot',
|
||||||
@@ -230,7 +230,11 @@ test('strategies', async () => {
|
|||||||
expect(strategy.destroy).toHaveBeenCalledWith(destroyOptions);
|
expect(strategy.destroy).toHaveBeenCalledWith(destroyOptions);
|
||||||
|
|
||||||
// eslint-disable-next-line id-length
|
// eslint-disable-next-line id-length
|
||||||
const send: GatewaySendPayload = { op: GatewayOpcodes.RequestGuildMembers, d: { guild_id: '1234', limit: 0 } };
|
const send: GatewaySendPayload = {
|
||||||
|
op: GatewayOpcodes.RequestGuildMembers,
|
||||||
|
// eslint-disable-next-line id-length
|
||||||
|
d: { guild_id: '1234', limit: 0, query: '' },
|
||||||
|
};
|
||||||
await manager.send(0, send);
|
await manager.send(0, send);
|
||||||
expect(strategy.send).toHaveBeenCalledWith(0, send);
|
expect(strategy.send).toHaveBeenCalledWith(0, send);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user