Created
June 27, 2017 22:44
-
-
Save hiimbex/6e52a33ff0c61ce857ccbb8ccc628e78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const expect = require('expect'); | |
const plugin = require('../index'); | |
const createProbot = require('probot'); | |
describe('plugin', () => { | |
beforeEach(() => { | |
config = { | |
data: { | |
content: Buffer.from('Thanks for making your first PR here!').toString('base64') | |
} | |
}; | |
//when probot run is called (probs will be changed in the near future) | |
probot = createProbot({secret: 'test'}); | |
//mocks authentication | |
github = {repos: { | |
getContent: expect.createSpy().andReturn(Promise.resolve(config)) | |
}, | |
issues: { | |
removeLabel: expect.createSpy() | |
}}; | |
probot.robot.auth = () => Promise.resolve(github); | |
probot.load(plugin); | |
event = { | |
payload: JSON.parse(JSON.stringify(require('./events/test_payload.json'))) | |
}; | |
}); | |
describe('first pull request', () => { | |
it('gets content', async () => { | |
//when web server recieves webhook | |
//emit triggers event == robot.on | |
probot.robot.webhook.emit('pull_request.opened', event); | |
console.log(github.repos.getContent); | |
expect(github.repos.getContent).toHaveBeenCalled(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment