Repository: discordjs/discord.js
File: packages/rest/__tests__/utils.test.ts (TypeScript)

Code before:
		}

		test("GIVEN object without index signature THEN TypeScript doesn't raise a type error", () => {
			// Previously, `makeURLSearchParams` used `Record<string, unknown>` as an input, but that meant that it
			// couldn't accept most interfaces, since they don't have an index signature. This test is to make sure
			// non-Records can be used without casting.

			const input = { foo: 'bar' } as TestInput;
			const params = makeURLSearchParams(input);

			expect([...params.entries()]).toEqual([['foo', 'bar']]);
		});

		test("GIVEN readonly object on a non-readonly generic type THEN TypeScript doesn't raise a type error", () => {
			// While `Readonly<T>` type was always accepted in `makeURLSearchParams`, this test is to ensure that we can
			// use the generic type and accept `Readonly<T>` rather than only [possibly] mutable `T`.

			const input = Object.freeze({ foo: 'bar' } as TestInput);
			const params = makeURLSearchParams<TestInput>(input);

			expect([...params.entries()]).toEqual([['foo', 'bar']]);
		});
	});
});

describe('option normalizaztion functions', () => {
	describe('rate limit offset', () => {
		const func: GetRateLimitOffsetFunction = (route) => {
			if (route === '/negative') return -150;
			if (route === '/high') return 150;
			return 50;
		};

		test('offset as number', () => {
			expect(normalizeRateLimitOffset(-150, '/negative')).toEqual(0);
			expect(normalizeRateLimitOffset(150, '/high')).toEqual(150);
			expect(normalizeRateLimitOffset(50, '/normal')).toEqual(50);
		});

		test('offset as function', () => {
			expect(normalizeRateLimitOffset(func, '/negative')).toEqual(0);
			expect(normalizeRateLimitOffset(func, '/high')).toEqual(150);
			expect(normalizeRateLimitOffset(func, '/normal')).toEqual(50);
		});
	});

	describe('retry backoff', () => {
		const body = {
			content: 'yo',
		};
		const func: GetRetryBackoffFunction = (_route, statusCode, retryCount) => {

Review comment (suggestion):
```suggestion
describe('option normalization functions', () => {
```

Code after:
		}

		test("GIVEN object without index signature THEN TypeScript doesn't raise a type error", () => {
			// Previously, `makeURLSearchParams` used `Record<string, unknown>` as an input, but that meant that it
			// couldn't accept most interfaces, since they don't have an index signature. This test is to make sure
			// non-Records can be used without casting.

			const input = { foo: 'bar' } as TestInput;
			const params = makeURLSearchParams(input);

			expect([...params.entries()]).toEqual([['foo', 'bar']]);
		});

		test("GIVEN readonly object on a non-readonly generic type THEN TypeScript doesn't raise a type error", () => {
			// While `Readonly<T>` type was always accepted in `makeURLSearchParams`, this test is to ensure that we can
			// use the generic type and accept `Readonly<T>` rather than only [possibly] mutable `T`.

			const input = Object.freeze({ foo: 'bar' } as TestInput);
			const params = makeURLSearchParams<TestInput>(input);

			expect([...params.entries()]).toEqual([['foo', 'bar']]);
		});
	});
});

describe('option normalization functions', () => {
	describe('rate limit offset', () => {
		const func: GetRateLimitOffsetFunction = (route) => {
			if (route === '/negative') return -150;
			if (route === '/high') return 150;
			return 50;
		};

		test('offset as number', () => {
			expect(normalizeRateLimitOffset(-150, '/negative')).toEqual(0);
			expect(normalizeRateLimitOffset(150, '/high')).toEqual(150);
			expect(normalizeRateLimitOffset(50, '/normal')).toEqual(50);
		});

		test('offset as function', () => {
			expect(normalizeRateLimitOffset(func, '/negative')).toEqual(0);
			expect(normalizeRateLimitOffset(func, '/high')).toEqual(150);
			expect(normalizeRateLimitOffset(func, '/normal')).toEqual(50);
		});
	});

	describe('retry backoff', () => {
		const body = {
			content: 'yo',
		};
		const func: GetRetryBackoffFunction = (_route, statusCode, retryCount) => {