Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. const expect = require('expect');
  2. const plugin = require('../index');
  3. const createProbot = require('probot');
  4.  
  5. describe('plugin', () => {
  6. beforeEach(() => {
  7. config = {
  8. data: {
  9. content: Buffer.from('Thanks for making your first PR here!').toString('base64')
  10. }
  11. };
  12. //when probot run is called (probs will be changed in the near future)
  13. probot = createProbot({secret: 'test'});
  14. //mocks authentication
  15. github = {repos: {
  16. getContent: expect.createSpy().andReturn(Promise.resolve(config))
  17. },
  18. issues: {
  19. removeLabel: expect.createSpy()
  20. }};
  21. probot.robot.auth = () => Promise.resolve(github);
  22.  
  23. probot.load(plugin);
  24.  
  25. event = {
  26. payload: JSON.parse(JSON.stringify(require('./events/test_payload.json')))
  27. };
  28. });
  29.  
  30. describe('first pull request', () => {
  31. it('gets content', async () => {
  32. //when web server recieves webhook
  33. //emit triggers event == robot.on
  34. probot.robot.webhook.emit('pull_request.opened', event);
  35. console.log(github.repos.getContent);
  36. expect(github.repos.getContent).toHaveBeenCalled();
  37. });
  38. });
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement