-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Octokit, type OctokitOptions } from "../src/index.js"; | ||
|
||
/** Checks whether the input is a class or not */ | ||
function isClass(input: unknown) { | ||
return typeof input === "function" && typeof input.prototype === "object"; | ||
} | ||
|
||
describe("Octokit", () => { | ||
test("Octokit should be a class", () => { | ||
expect(isClass(Octokit)).toBe(true); | ||
}); | ||
|
||
const baseOptions: OctokitOptions = { | ||
appId: 15483, | ||
clientId: "", | ||
clientSecret: "", | ||
privateKey: "-----BEGIN RSA PRIVATE KEY-----\ntest test test\n-----END RSA PRIVATE KEY-----" | ||
}; | ||
|
||
test("Without installationId", () => { | ||
const octokit = new Octokit(baseOptions); | ||
expect(octokit.options).toStrictEqual(baseOptions); | ||
|
||
expect(octokit.userAgent).toBe("@ijsblokje/octokit (https://github.com/ijsKoud/ijsblokje)"); | ||
expect(typeof octokit.request === "function").toBe(true); | ||
expect(typeof octokit.hook === "function").toBe(true); | ||
expect(typeof octokit.graphql === "function").toBe(true); | ||
expect(typeof octokit.log === "object").toBe(true); | ||
}); | ||
|
||
test("With installationId", () => { | ||
const options: OctokitOptions = { ...baseOptions, installationId: 11150 }; | ||
const octokit = new Octokit(options); | ||
expect(octokit.options).toStrictEqual(options); | ||
}); | ||
|
||
test("Octokit#new()", () => { | ||
const octokit = new Octokit(baseOptions); | ||
const clonedOctokit = octokit.new(); | ||
|
||
expect(clonedOctokit instanceof Octokit).toBe(true); | ||
expect(clonedOctokit.options).toStrictEqual(baseOptions); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./", | ||
"noEmit": true, | ||
"incremental": true, | ||
"tsBuildInfoFile": ".tsbuildinfo-2", | ||
"types": ["vitest/globals"] | ||
}, | ||
"include": ["*.test.ts"], | ||
"references": [{ "path": "../" }] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["./src/**/*.ts"], | ||
"compilerOptions": { "outDir": "./dist" } | ||
"compilerOptions": { "outDir": "./dist", "composite": true } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, | ||
cache: { | ||
dir: "../../node_modules/.vitest" | ||
} | ||
}, | ||
esbuild: { | ||
target: "ES2020" | ||
} | ||
}); |