From b02e71f870b717bac9215820ea5df54561d536c3 Mon Sep 17 00:00:00 2001 From: Bob van der Linden Date: Sat, 25 Aug 2018 01:09:28 +0200 Subject: [PATCH] add test for no configuration --- test/integration.test.ts | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/integration.test.ts b/test/integration.test.ts index ff2d0426a..795ee3e77 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -84,3 +84,45 @@ it('full happy path', async () => { expect(github.pullRequests.merge).toHaveBeenCalled() }) + +it('no configuration should not schedule any pull request', async () => { + const app = new Application() + + jest.mock('../src/pull-request-handler', () => { + return { + schedulePullRequestTrigger: jest.fn() + } + }) + + const github: any = { + repos: { + getContent: () => Promise.reject({ code: 404 }) + } + } as DeepPartial + + app.auth = () => { + return Promise.resolve(github) as any + } + + app.load(probotAutoMerge) + + await app.receive({ + event: 'pull_request', + payload: { + action: 'opened', + repository: { + owner: { + login: 'bobvanderlinden' + }, + name: 'probot-auto-merge' + }, + pull_request: { + number: 1 + } + } + } as any) + + const module: any = require('../src/pull-request-handler') + + expect(module.schedulePullRequestTrigger).not.toHaveBeenCalled() +})