Skip to content

Commit

Permalink
test: fix handler test
Browse files Browse the repository at this point in the history
  • Loading branch information
hfreire committed May 22, 2019
1 parent b2ab950 commit cac466d
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions test/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,26 @@ describe('Handler', () => {

beforeAll(() => {
GitHubWrapper = require('@dog-ai/github-wrapper')
//jest.mock('@dog-ai/github-wrapper')
jest.mock('@dog-ai/github-wrapper')
})

describe('when handling a schedule event', () => {
const token = 'my-token'
const orgs = 'my-owner'
let mergeGreenkeeperPullRequests

beforeAll(() => {
//process.env.GH_TOKEN = token
//process.env.GH_ORGS = orgs

mergeGreenkeeperPullRequests = jest.fn().mockImplementation(() => {
return {}
})
process.env.GH_TOKEN = token
process.env.GH_ORGS = orgs
})

beforeEach(() => {
//GitHubWrapper.mockImplementation(() => {
// return { mergeGreenkeeperPullRequests }
//})

subject = require('../src/handler')
})

it('should call merge greenkeeper pull requests', async () => {
jest.setTimeout(400000)
it('should merge greenkeeper pull requests for both the authenticated user and the org', async () => {
await subject()

expect(mergeGreenkeeperPullRequests).toHaveBeenCalledTimes(2)
expect(GitHubWrapper.mock.instances[ 0 ].mergeGreenkeeperPullRequests).toHaveBeenCalledTimes(2)
})
})
})

0 comments on commit cac466d

Please sign in to comment.