Skip to content

Commit

Permalink
initial work
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvanderlinden committed Nov 22, 2018
1 parent 8c31913 commit 4d9e1ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions test/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Config, defaultConfig } from '../src/config'
import { Application, ApplicationFunction } from 'probot'
import { GitHubAPI } from 'probot/lib/github'
import { LoggerWithTarget } from 'probot/lib/wrap-logger'
import { Response, GitdataDeleteReferenceResponse } from '@octokit/rest'

export const defaultPullRequestInfo: PullRequestInfo = {
number: 1,
Expand Down Expand Up @@ -294,14 +295,21 @@ export function createCheckSuiteCompletedEvent (pullRequest: PullRequestReferenc
}
}

export function createOkResponse (): any {
export function createOkResponse<T> (): (...args: any[]) => Response<T> {
return jest.fn(() => ({ status: 200 }))
}

export function createGithubApiFromPullRequestInfo (opts: {
pullRequestInfo: PullRequestInfo,
config: string
}): GitHubAPI {
return createPartialGithubApiFromPullRequestInfo(opts) as GitHubAPI
}

function createPartialGithubApiFromPullRequestInfo (opts: {
pullRequestInfo: PullRequestInfo,
config: string
}): DeepPartial<GitHubAPI> {
const pullRequestQueryResult: PullRequestQueryResult = {
repository: {
pullRequest: opts.pullRequestInfo
Expand Down Expand Up @@ -331,9 +339,9 @@ export function createGithubApiFromPullRequestInfo (opts: {
})
},
gitdata: {
deleteReference: createOkResponse()
deleteReference: createOkResponse<GitdataDeleteReferenceResponse>()
}
} as any
}
}

export function createGetContent (paths: { [key: string]: () => Buffer }): any {
Expand Down
2 changes: 1 addition & 1 deletion test/status-report.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CheckRun } from './../lib/github-models.d'
import { CheckRun } from './../src/github-models'
import { createPullRequestInfo, createPullRequestContext, createGithubApi, createCheckRun, createConfig } from './mock'
import { updateStatusReportCheck } from '../src/status-report'

Expand Down

0 comments on commit 4d9e1ac

Please sign in to comment.