mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
test: fix type errors (#11325)
* test: fix type errors * chore: use MockedFunction --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable id-length */
|
||||
/* eslint-disable promise/prefer-await-to-then */
|
||||
// @ts-nocheck
|
||||
import { performance } from 'node:perf_hooks';
|
||||
import { MockAgent, setGlobalDispatcher } from 'undici';
|
||||
import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor';
|
||||
@@ -137,7 +136,7 @@ test('Handle unexpected 429', async () => {
|
||||
});
|
||||
|
||||
expect(await unexpectedLimit).toStrictEqual({ test: true });
|
||||
expect(performance.now()).toBeGreaterThanOrEqual(previous + 1_000);
|
||||
expect(firstResolvedTime!).toBeGreaterThanOrEqual(previous + 1_000);
|
||||
});
|
||||
|
||||
test('server responding too slow', async () => {
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { Buffer, File as NativeFile } from 'node:buffer';
|
||||
import { Buffer, File } from 'node:buffer';
|
||||
import { URLSearchParams } from 'node:url';
|
||||
import { DiscordSnowflake } from '@sapphire/snowflake';
|
||||
import type { Snowflake } from 'discord-api-types/v10';
|
||||
import { Routes } from 'discord-api-types/v10';
|
||||
import { type FormData, fetch } from 'undici';
|
||||
import { File as UndiciFile, MockAgent, setGlobalDispatcher } from 'undici';
|
||||
import { MockAgent, setGlobalDispatcher } from 'undici';
|
||||
import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor.js';
|
||||
import { beforeEach, afterEach, test, expect, vitest } from 'vitest';
|
||||
import { REST } from '../src/index.js';
|
||||
import { genPath } from './util.js';
|
||||
|
||||
const File = NativeFile ?? UndiciFile;
|
||||
|
||||
const newSnowflake: Snowflake = DiscordSnowflake.generate().toString();
|
||||
|
||||
const api = new REST().setToken('A-Very-Fake-Token');
|
||||
|
||||
@@ -82,7 +82,7 @@ test('resolveBody', async () => {
|
||||
const fd = new globalThis.FormData();
|
||||
fd.append('key', 'value');
|
||||
|
||||
const resolved = await resolveBody(fd);
|
||||
const resolved = await resolveBody(fd as UndiciFormData);
|
||||
|
||||
expect(resolved).toBeInstanceOf(UndiciFormData);
|
||||
expect([...(resolved as UndiciFormData).entries()]).toStrictEqual([['key', 'value']]);
|
||||
|
||||
Reference in New Issue
Block a user