diff --git a/test/handler.js b/test/handler.js index e546d565..1d8c4a97 100644 --- a/test/handler.js +++ b/test/handler.js @@ -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) }) }) })