mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-14 12:31:14 +00:00
test: noImplicitAny
This commit is contained in:
parent
2532386159
commit
1f3d2a6328
2 changed files with 39 additions and 59 deletions
|
|
@ -1,12 +1,13 @@
|
|||
import {
|
||||
findPreviousComment,
|
||||
createComment,
|
||||
updateComment,
|
||||
deleteComment
|
||||
} from "../src/comment"
|
||||
|
||||
import {getOctokit} from "@actions/github"
|
||||
import * as core from "@actions/core"
|
||||
|
||||
import {
|
||||
createComment,
|
||||
deleteComment,
|
||||
findPreviousComment,
|
||||
updateComment
|
||||
} from "../src/comment"
|
||||
|
||||
jest.mock("@actions/core", () => ({
|
||||
warning: jest.fn()
|
||||
}))
|
||||
|
|
@ -48,16 +49,9 @@ it("findPreviousComment", async () => {
|
|||
body: "previous message\n<!-- Sticky Pull Request CommentTypeB -->"
|
||||
}
|
||||
]
|
||||
const octokit: any = {
|
||||
graphql: jest.fn(() =>
|
||||
Promise.resolve({
|
||||
viewer: authenticatedUser
|
||||
})
|
||||
),
|
||||
rest: {
|
||||
issues: {
|
||||
listComments: jest.fn(() =>
|
||||
Promise.resolve({
|
||||
const octokit = getOctokit("github-token")
|
||||
jest.spyOn(octokit, "graphql").mockResolvedValue({viewer: authenticatedUser})
|
||||
jest.spyOn(octokit.rest.issues, "listComments").mockResolvedValue({
|
||||
data: [
|
||||
commentWithCustomHeader,
|
||||
otherUserComment,
|
||||
|
|
@ -65,11 +59,7 @@ it("findPreviousComment", async () => {
|
|||
headerFirstComment,
|
||||
...otherComments
|
||||
]
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} as any)
|
||||
|
||||
expect(await findPreviousComment(octokit, repo, 123, "")).toBe(comment)
|
||||
expect(await findPreviousComment(octokit, repo, 123, "TypeA")).toBe(
|
||||
|
|
@ -86,16 +76,12 @@ it("findPreviousComment", async () => {
|
|||
})
|
||||
|
||||
describe("updateComment", () => {
|
||||
let octokit
|
||||
const octokit = getOctokit("github-token")
|
||||
|
||||
beforeEach(() => {
|
||||
octokit = {
|
||||
rest: {
|
||||
issues: {
|
||||
updateComment: jest.fn(() => Promise.resolve())
|
||||
}
|
||||
}
|
||||
}
|
||||
jest
|
||||
.spyOn<any, string>(octokit.rest.issues, "updateComment")
|
||||
.mockResolvedValue("")
|
||||
})
|
||||
|
||||
it("with comment body", async () => {
|
||||
|
|
@ -143,16 +129,12 @@ describe("updateComment", () => {
|
|||
})
|
||||
|
||||
describe("createComment", () => {
|
||||
let octokit
|
||||
const octokit = getOctokit("github-token")
|
||||
|
||||
beforeEach(() => {
|
||||
octokit = {
|
||||
rest: {
|
||||
issues: {
|
||||
createComment: jest.fn(() => Promise.resolve())
|
||||
}
|
||||
}
|
||||
}
|
||||
jest
|
||||
.spyOn<any, string>(octokit.rest.issues, "createComment")
|
||||
.mockResolvedValue("")
|
||||
})
|
||||
|
||||
it("with comment body or previousBody", async () => {
|
||||
|
|
@ -183,13 +165,11 @@ describe("createComment", () => {
|
|||
})
|
||||
|
||||
it("deleteComment", async () => {
|
||||
const octokit: any = {
|
||||
rest: {
|
||||
issues: {
|
||||
deleteComment: jest.fn(() => Promise.resolve())
|
||||
}
|
||||
}
|
||||
}
|
||||
const octokit = getOctokit("github-token")
|
||||
|
||||
jest
|
||||
.spyOn(octokit.rest.issues, "deleteComment")
|
||||
.mockReturnValue(undefined as any)
|
||||
expect(await deleteComment(octokit, repo, 456)).toBeUndefined()
|
||||
expect(octokit.rest.issues.deleteComment).toBeCalledWith({
|
||||
comment_id: 456,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
||||
"outDir": "./lib" /* Redirect output structure to the directory. */,
|
||||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue