From f6a2da7fa2d5576bdfbdb1ab438015562d76525b Mon Sep 17 00:00:00 2001 From: uzlopak Date: Sat, 21 Oct 2023 02:20:38 +0200 Subject: [PATCH 1/3] export ThrottlingOptions --- src/index.ts | 2 ++ test/octokit.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index b766184b..ff951c59 100644 --- a/src/index.ts +++ b/src/index.ts @@ -181,3 +181,5 @@ declare module "@octokit/core/dist-types/types.d" { throttle?: ThrottlingOptions; } } + +export type { ThrottlingOptions }; diff --git a/test/octokit.ts b/test/octokit.ts index 41bc93c8..6d3a7aa5 100644 --- a/test/octokit.ts +++ b/test/octokit.ts @@ -1,6 +1,6 @@ import { Octokit } from "@octokit/core"; import { RequestError } from "@octokit/request-error"; -import { throttling } from "../src"; +import { throttling, ThrottlingOptions } from "../src"; function testPlugin(octokit: Octokit) { const t0 = Date.now(); @@ -34,4 +34,12 @@ function testPlugin(octokit: Octokit) { return { __requestLog, __requestTimings }; } +const options: ThrottlingOptions = { + enabled: true, + onRateLimit: () => {}, + onSecondaryRateLimit: () => {}, +}; + +options.enabled = false; + export const TestOctokit = Octokit.plugin(testPlugin, throttling); From 7dac512844e03b5b2376c95af22973f5191f0ef4 Mon Sep 17 00:00:00 2001 From: uzlopak Date: Sat, 21 Oct 2023 02:26:38 +0200 Subject: [PATCH 2/3] fix test coverage --- test/octokit.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/octokit.ts b/test/octokit.ts index 6d3a7aa5..131c27c6 100644 --- a/test/octokit.ts +++ b/test/octokit.ts @@ -41,5 +41,7 @@ const options: ThrottlingOptions = { }; options.enabled = false; +options.onRateLimit(10, {}, {} as Octokit, 0); +options.onSecondaryRateLimit(10, {}, {} as Octokit, 0); export const TestOctokit = Octokit.plugin(testPlugin, throttling); From 56743dee3485595fde41ed55bba04aadbd48dafe Mon Sep 17 00:00:00 2001 From: uzlopak Date: Sat, 21 Oct 2023 02:31:01 +0200 Subject: [PATCH 3/3] fix test coverage --- test/exports.test.ts | 16 ++++++++++++++++ test/octokit.ts | 12 +----------- 2 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 test/exports.test.ts diff --git a/test/exports.test.ts b/test/exports.test.ts new file mode 100644 index 00000000..f7cad802 --- /dev/null +++ b/test/exports.test.ts @@ -0,0 +1,16 @@ +import type { ThrottlingOptions } from "../src"; +import type { Octokit } from "@octokit/core"; + +describe("Exports", function () { + it("Should export ThrottlingOptions", function () { + const options: ThrottlingOptions = { + enabled: true, + onRateLimit: () => {}, + onSecondaryRateLimit: () => {}, + }; + + options.enabled = false; + options.onRateLimit(10, {}, {} as Octokit, 0); + options.onSecondaryRateLimit(10, {}, {} as Octokit, 0); + }); +}); diff --git a/test/octokit.ts b/test/octokit.ts index 131c27c6..41bc93c8 100644 --- a/test/octokit.ts +++ b/test/octokit.ts @@ -1,6 +1,6 @@ import { Octokit } from "@octokit/core"; import { RequestError } from "@octokit/request-error"; -import { throttling, ThrottlingOptions } from "../src"; +import { throttling } from "../src"; function testPlugin(octokit: Octokit) { const t0 = Date.now(); @@ -34,14 +34,4 @@ function testPlugin(octokit: Octokit) { return { __requestLog, __requestTimings }; } -const options: ThrottlingOptions = { - enabled: true, - onRateLimit: () => {}, - onSecondaryRateLimit: () => {}, -}; - -options.enabled = false; -options.onRateLimit(10, {}, {} as Octokit, 0); -options.onSecondaryRateLimit(10, {}, {} as Octokit, 0); - export const TestOctokit = Octokit.plugin(testPlugin, throttling);