Skip to content

Instantly share code, notes, and snippets.

@hiimbex
Created June 27, 2017 22:44
Show Gist options
  • Save hiimbex/6e52a33ff0c61ce857ccbb8ccc628e78 to your computer and use it in GitHub Desktop.
Save hiimbex/6e52a33ff0c61ce857ccbb8ccc628e78 to your computer and use it in GitHub Desktop.
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