mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
rest: prefer arrayBuffer over buffer (#7318)
This commit is contained in:
@@ -205,12 +205,14 @@ test('urlEncoded', async () => {
|
||||
['code', 'very-invalid-code'],
|
||||
]);
|
||||
expect(
|
||||
await api.post('/urlEncoded', {
|
||||
body,
|
||||
passThroughBody: true,
|
||||
auth: false,
|
||||
}),
|
||||
).toStrictEqual(Buffer.from(body.toString()));
|
||||
new Uint8Array(
|
||||
(await api.post('/urlEncoded', {
|
||||
body,
|
||||
passThroughBody: true,
|
||||
auth: false,
|
||||
})) as ArrayBuffer,
|
||||
),
|
||||
).toStrictEqual(new Uint8Array(Buffer.from(body.toString())));
|
||||
});
|
||||
|
||||
test('postEcho', async () => {
|
||||
|
||||
@@ -259,12 +259,13 @@ test('Significant Invalid Requests', async () => {
|
||||
|
||||
test('Handle standard rate limits', async () => {
|
||||
const [a, b, c] = [api.get('/standard'), api.get('/standard'), api.get('/standard')];
|
||||
const uint8 = new Uint8Array();
|
||||
|
||||
expect(await a).toStrictEqual(Buffer.alloc(0));
|
||||
expect(new Uint8Array((await a) as ArrayBuffer)).toStrictEqual(uint8);
|
||||
const previous1 = performance.now();
|
||||
expect(await b).toStrictEqual(Buffer.alloc(0));
|
||||
expect(new Uint8Array((await b) as ArrayBuffer)).toStrictEqual(uint8);
|
||||
const previous2 = performance.now();
|
||||
expect(await c).toStrictEqual(Buffer.alloc(0));
|
||||
expect(new Uint8Array((await c) as ArrayBuffer)).toStrictEqual(uint8);
|
||||
const now = performance.now();
|
||||
expect(previous2).toBeGreaterThanOrEqual(previous1 + 250);
|
||||
expect(now).toBeGreaterThanOrEqual(previous2 + 250);
|
||||
|
||||
@@ -11,7 +11,7 @@ export function parseResponse(res: Response): Promise<unknown> {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
return res.buffer();
|
||||
return res.arrayBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user