How to use the probot.createRobot function in probot

To help you get started, we’ve selected a few probot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github erickzhao / invite-contributors / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()
    plugin(robot)

    // mock github api
    github = {
      orgs: {
        getOrgMembership: expect.createSpy().andThrow(new Error('Not Found')),
        addOrgMembership: expect.createSpy(),
        getTeams: expect.createSpy().andReturn(Promise.resolve({
          data: [{
            'id': 1,
            'url': 'https://api.github.com/teams/1',
            'name': 'Justice League',
            'slug': 'justice-league',
            'description': 'A great team.',
            'privacy': 'closed',
            'permission': 'admin',
github mithro / autolabeler / test / index.js View on Github external
beforeEach(() => {
    // Create a new Robot to run our plugin
    robot = createRobot()

    // Load the plugin
    plugin(robot)

    // Mock out the GitHub API
    github = {
      repos: {
        // Response for getting content from '.github/ISSUE_REPLY_TEMPLATE.md'
        getContent: expect.createSpy().andReturn(Promise.resolve({
          data: {
            content: Buffer.from(config).toString('base64')
          }
        }))
      },

      pullRequests: {
github probot / autoresponder / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()

    // Load the plugin
    plugin(robot)

    // Mock out the GitHub API
    github = {
      repos: {
        // Response for getting content from '.github/ISSUE_REPLY_TEMPLATE.md'
        getContent: expect.createSpy().andReturn(Promise.resolve({
          data: {
            content: Buffer.from(`Hello World!`).toString('base64')
          }
        }))
      },

      issues: {
github tbarn / guys-bot / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()
    plugin(robot)
    // This is an easy way to mock out the GitHub API
    github = {
      issues: {
        createComment: expect.createSpy().andReturn(Promise.resolve({
          // Whatever the GitHub API should return
        }))
      }
    }
    // Passes the mocked out GitHub API into out robot instance
    robot.auth = () => Promise.resolve(github)
  })
github probot / reminders / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()

    // Deep clone so later modifications don't mutate this.
    commentEvent = JSON.parse(JSON.stringify(require('./fixtures/issue_comment.created')))
    issue = {
      body: 'hello world\n\n',
      number: 2,
      labels: [{
        url: 'https://api.github.com/repos/baxterthehacker/public-repo/labels/reminder',
        name: 'reminder',
        color: 'fc2929'
      }]
    }

    // Load the plugin
    // Mock out the GitHub API
    github = {
github bkeepers / workflow / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()
    app(robot)

    github = {
      repos: {
        getContent: jest.fn().mockReturnValue(Promise.resolve({}))
      },
      issues: {
        createComment: jest.fn(),
        edit: jest.fn()
      }
    }
  })
github JasonEtco / todo / __tests__ / languages.js View on Github external
function gimmeRobot () {
  const cfg = fs.readFileSync(path.join(__dirname, 'fixtures', 'configs', 'noBlob.yml'), 'utf8')
  let robot
  let github
  const content = (str) => Promise.resolve({ data: { content: Buffer.from(str) } })

  robot = createRobot()
  app(robot)

  github = {
    issues: {
      getForRepo: jest.fn().mockReturnValue(Promise.resolve([])),
      create: jest.fn(),
      createLabel: jest.fn()
    },
    search: {
      issues: jest.fn().mockReturnValue(Promise.resolve([{data: {items: [], total_count: 0}}]))
    },
    paginate: jest.fn().mockReturnValue(Promise.resolve([])),
    repos: {
      getContent: jest.fn((obj) => {
        if (obj.path.includes('config.yml')) {
          return content(cfg)
github behaviorbot / update-docs / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()
    plugin(robot)

    github = {
      repos: {
        getContent: expect.createSpy().andReturn(Promise.resolve({
          data: {
            content: Buffer.from(`whiteList:\n  - bug\n  - chore`).toString('base64')
          }
        }))
      },
      issues: {
        createComment: expect.createSpy()
      },
      pullRequests: {
        getFiles: expect.createSpy().andReturn(Promise.resolve({
          data: [{filename: 'help.yml'}, {filename: 'index.js'}]
github probot / settings / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()
    robot.auth = () => Promise.resolve({})

    event = {
      event: 'push',
      payload: JSON.parse(JSON.stringify(require('./fixtures/events/push.settings.json')))
    }
    sync = expect.createSpy()

    plugin(robot, {}, {sync, FILE_NAME: '.github/settings.yml'})
  })