Skip to content

Commit

Permalink
Merge pull request #168 from bobvanderlinden/pr-fix-mock-types
Browse files Browse the repository at this point in the history
Update mocks with new package APIs
  • Loading branch information
probot-auto-merge[bot] committed Feb 16, 2019
2 parents 96b9d46 + 1c5504e commit 55976a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/integration.test.ts
Expand Up @@ -195,7 +195,7 @@ it('pending check run', async () => {
expect(github.query).toHaveBeenCalled()
expect(setTimeout).toHaveBeenCalled()
expect(github.pullRequests.merge).not.toHaveBeenCalled()
github.query = jest.fn(() => {
github.query = jest.fn(async () => {
return {
repository: {
pullRequest: {
Expand Down
11 changes: 10 additions & 1 deletion test/mock.ts
Expand Up @@ -346,8 +346,17 @@ export function createCheckSuiteCompletedEvent (pullRequest: PullRequestReferenc
}
}

export function createResponse<T> (options: Partial<Response<T>>): Response<T> {
return {
data: null,
status: 200,
headers: {},
...options
} as any as Response<T>
}

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

export function createGithubApiFromPullRequestInfo (opts: {
Expand Down

0 comments on commit 55976a0

Please sign in to comment.