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 {
|
import {getOctokit} from "@actions/github"
|
||||||
findPreviousComment,
|
|
||||||
createComment,
|
|
||||||
updateComment,
|
|
||||||
deleteComment
|
|
||||||
} from "../src/comment"
|
|
||||||
|
|
||||||
import * as core from "@actions/core"
|
import * as core from "@actions/core"
|
||||||
|
|
||||||
|
import {
|
||||||
|
createComment,
|
||||||
|
deleteComment,
|
||||||
|
findPreviousComment,
|
||||||
|
updateComment
|
||||||
|
} from "../src/comment"
|
||||||
|
|
||||||
jest.mock("@actions/core", () => ({
|
jest.mock("@actions/core", () => ({
|
||||||
warning: jest.fn()
|
warning: jest.fn()
|
||||||
}))
|
}))
|
||||||
|
|
@ -48,28 +49,17 @@ it("findPreviousComment", async () => {
|
||||||
body: "previous message\n<!-- Sticky Pull Request CommentTypeB -->"
|
body: "previous message\n<!-- Sticky Pull Request CommentTypeB -->"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const octokit: any = {
|
const octokit = getOctokit("github-token")
|
||||||
graphql: jest.fn(() =>
|
jest.spyOn(octokit, "graphql").mockResolvedValue({viewer: authenticatedUser})
|
||||||
Promise.resolve({
|
jest.spyOn(octokit.rest.issues, "listComments").mockResolvedValue({
|
||||||
viewer: authenticatedUser
|
data: [
|
||||||
})
|
commentWithCustomHeader,
|
||||||
),
|
otherUserComment,
|
||||||
rest: {
|
comment,
|
||||||
issues: {
|
headerFirstComment,
|
||||||
listComments: jest.fn(() =>
|
...otherComments
|
||||||
Promise.resolve({
|
]
|
||||||
data: [
|
} as any)
|
||||||
commentWithCustomHeader,
|
|
||||||
otherUserComment,
|
|
||||||
comment,
|
|
||||||
headerFirstComment,
|
|
||||||
...otherComments
|
|
||||||
]
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(await findPreviousComment(octokit, repo, 123, "")).toBe(comment)
|
expect(await findPreviousComment(octokit, repo, 123, "")).toBe(comment)
|
||||||
expect(await findPreviousComment(octokit, repo, 123, "TypeA")).toBe(
|
expect(await findPreviousComment(octokit, repo, 123, "TypeA")).toBe(
|
||||||
|
|
@ -86,16 +76,12 @@ it("findPreviousComment", async () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("updateComment", () => {
|
describe("updateComment", () => {
|
||||||
let octokit
|
const octokit = getOctokit("github-token")
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
octokit = {
|
jest
|
||||||
rest: {
|
.spyOn<any, string>(octokit.rest.issues, "updateComment")
|
||||||
issues: {
|
.mockResolvedValue("")
|
||||||
updateComment: jest.fn(() => Promise.resolve())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("with comment body", async () => {
|
it("with comment body", async () => {
|
||||||
|
|
@ -143,16 +129,12 @@ describe("updateComment", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("createComment", () => {
|
describe("createComment", () => {
|
||||||
let octokit
|
const octokit = getOctokit("github-token")
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
octokit = {
|
jest
|
||||||
rest: {
|
.spyOn<any, string>(octokit.rest.issues, "createComment")
|
||||||
issues: {
|
.mockResolvedValue("")
|
||||||
createComment: jest.fn(() => Promise.resolve())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("with comment body or previousBody", async () => {
|
it("with comment body or previousBody", async () => {
|
||||||
|
|
@ -183,13 +165,11 @@ describe("createComment", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("deleteComment", async () => {
|
it("deleteComment", async () => {
|
||||||
const octokit: any = {
|
const octokit = getOctokit("github-token")
|
||||||
rest: {
|
|
||||||
issues: {
|
jest
|
||||||
deleteComment: jest.fn(() => Promise.resolve())
|
.spyOn(octokit.rest.issues, "deleteComment")
|
||||||
}
|
.mockReturnValue(undefined as any)
|
||||||
}
|
|
||||||
}
|
|
||||||
expect(await deleteComment(octokit, repo, 456)).toBeUndefined()
|
expect(await deleteComment(octokit, repo, 456)).toBeUndefined()
|
||||||
expect(octokit.rest.issues.deleteComment).toBeCalledWith({
|
expect(octokit.rest.issues.deleteComment).toBeCalledWith({
|
||||||
comment_id: 456,
|
comment_id: 456,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"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'. */
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
||||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
"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. */
|
"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. */
|
"strict": true /* Enable all strict type-checking options. */,
|
||||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
"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'. */
|
"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"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue