Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement