Skip to content

Commit

Permalink
Add failing test to ensure the change of #399
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jun 27, 2022
1 parent f9e5d46 commit 041199d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// This code is not executed, only statically analyzed using `tsc --noEmit`
import { EndpointInterface, Endpoints } from "./src";
import { EndpointInterface, Endpoints, RequestInterface, RequestParameters, Route } from "./src";

const endpoint = {} as EndpointInterface;
function assertString(type: string) {}
function assertNullableString(type: string | null | undefined) {}
function assertArray(type: unknown[]) {}
const assertPaginate = {} as {
<R extends Route>(route: R): Promise<void>;
<R extends RequestInterface>(request: R): Promise<void>;
};

const createIssueOptions = {
owner: "octocat",
Expand Down Expand Up @@ -37,3 +41,18 @@ assertNullableString(test2.data.Resources[0].name.givenName);

const test3 = {} as Endpoints["POST /user/repos"]["parameters"];
assertString(test3.name);

const checkRunsRoute = 'GET /repos/{owner}/{repo}/commits/{ref}/check-runs' as const;

assertPaginate(checkRunsRoute);

const listForRef = {} as {
(params?: RequestParameters & Omit<Endpoints["GET /repos/{owner}/{repo}/commits/{ref}/check-runs"]["parameters"], "baseUrl" | "headers" | "mediaType">): Promise<Endpoints[typeof checkRunsRoute]["response"]>;
defaults: RequestInterface["defaults"];
endpoint: EndpointInterface<{
url: string;
}>;
};

// octokit.paginate can take `request` method. ref: https://github.com/octokit/plugin-paginate-rest.js/blob/b3fb11e301f9658554e110aeebbd7cbb89b8aad4/README.md?plain=1#L117-L126
assertPaginate(listForRef);

0 comments on commit 041199d

Please sign in to comment.