diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts index 9734eddf0..f301e1aa5 100644 --- a/test/typescript-validate.ts +++ b/test/typescript-validate.ts @@ -4,14 +4,26 @@ import { createAppAuth } from "../src"; +function expectType(what: T) {} + +const auth = createAppAuth({ + appId: 1, + privateKey: "-----BEGIN PRIVATE KEY-----\n...", + clientId: "lv1.1234567890abcdef", + clientSecret: "1234567890abcdef12341234567890abcdef1234", +}); + export async function readmeExample() { - const auth = createAppAuth({ - appId: 1, - privateKey: "-----BEGIN PRIVATE KEY-----\n...", - clientId: "lv1.1234567890abcdef", - clientSecret: "1234567890abcdef12341234567890abcdef1234", - }); + // Retrieve an oauth-access token + const userAuthentication = await auth({ type: "oauth-user", code: "123456" }); + expectType<"token">(userAuthentication.type); +} + +export async function issue268() { // Retrieve an oauth-access token - await auth({ type: "oauth-user", code: "123456" }); + const userAuthentication = await auth({ type: "installation" }); + + expectType<"token">(userAuthentication.type); + expectType<"tokenType">(userAuthentication.tokenType); }