Skip to content

Commit

Permalink
Test for manually delivering events
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Jun 27, 2017
1 parent 2f6a520 commit 9dd1afd
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/index.js
@@ -0,0 +1,40 @@
const expect = require('expect');
const createProbot = require('..');

describe('Probot', () => {
let probot;
let event;

beforeEach(() => {
probot = createProbot();
probot.robot.auth = () => Promise.resolve({});

event = {
event: 'push',
payload: require('./fixtures/webhook/push')
};
});

describe('receive', () => {
it('delivers the event', async () => {
spy = expect.createSpy();
probot.load(robot => robot.on('push', spy));

await probot.receive(event);

expect(spy).toHaveBeenCalled();
});

it('raises errors thrown in plugins', async () => {
spy = expect.createSpy();

probot.load(robot => robot.on('push', () => {
throw new Error('something happened');
}));

expect(async () => {
await probot.receive(event);
}).toThrow();
});
});
});

0 comments on commit 9dd1afd

Please sign in to comment.