<commit_before>const { gimmeRobot, loadConfig } = require('./helpers')
const pullRequestOpened = require('./fixtures/payloads/pull_request.opened.json')

describe('pr-comment-handler', () => {
  let robot, github
  const event = { event: 'pull_request', payload: pullRequestOpened }

  beforeEach(() => {
    const gimme = gimmeRobot()
    robot = gimme.robot
    github = gimme.github
  })

  it('comments on a pull request', async () => {
    await robot.receive(event)
    expect(github.issues.createComment).toHaveBeenCalledTimes(1)
    expect(github.issues.createComment.mock.calls[0]).toMatchSnapshot()
  })

  it('comments on a pull request and mentions the assigned user', async () => {
    github.repos.getContent.mockReturnValueOnce(loadConfig('autoAssignString'))
    await robot.receive(event)
    expect(github.issues.createComment.mock.calls[0]).toMatchSnapshot()
  })

  it('comments on a pull request and mentions the assigned users', async () => {
    github.repos.getContent.mockReturnValueOnce(loadConfig('autoAssignArr'))
    await robot.receive(event)
    expect(github.issues.createComment.mock.calls[0]).toMatchSnapshot()
  })

  it('does not create duplicate comments', async () => {
    github.issues.getComments.mockReturnValueOnce(Promise.resolve({ data: [{
      body: '## I am an example title'
    }] }))

    await robot.receive(event)
    expect(github.issues.createComment).toHaveBeenCalledTimes(0)
  })
})<commit_msg>Add multi test to PR handler<commit_after>const { gimmeRobot, loadConfig, loadDiff } = require('./helpers')
const pullRequestOpened = require('./fixtures/payloads/pull_request.opened.json')

describe('pr-comment-handler', () => {
  let robot, github
  const event = { event: 'pull_request', payload: pullRequestOpened }

  beforeEach(() => {
    const gimme = gimmeRobot()
    robot = gimme.robot
    github = gimme.github
  })

  it('comments on a pull request', async () => {
    await robot.receive(event)
    expect(github.issues.createComment).toHaveBeenCalledTimes(1)
    expect(github.issues.createComment.mock.calls[0]).toMatchSnapshot()
  })

  it('comments on a pull request and mentions the assigned user', async () => {
    github.repos.getContent.mockReturnValueOnce(loadConfig('autoAssignString'))
    await robot.receive(event)
    expect(github.issues.createComment.mock.calls[0]).toMatchSnapshot()
  })

  it('comments on a pull request and mentions the assigned users', async () => {
    github.repos.getContent.mockReturnValueOnce(loadConfig('autoAssignArr'))
    await robot.receive(event)
    expect(github.issues.createComment.mock.calls[0]).toMatchSnapshot()
  })

  it('does not create duplicate comments', async () => {
    github.issues.getComments.mockReturnValueOnce(Promise.resolve({ data: [{
      body: '## I am an example title'
    }] }))

    await robot.receive(event)
    expect(github.issues.createComment).toHaveBeenCalledTimes(0)
  })

  it('creates many (5) comments', async () => {
    github.pullRequests.get.mockReturnValueOnce(loadDiff('many'))
    await robot.receive(event)
    expect(github.issues.createComment).toHaveBeenCalledTimes(5)
  })
})
{'fraction_non_alphanumeric': 0.1390391345847916, 'fraction_numerical': 0.003818008272351257, 'mean_word_length': 4.458333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '651248', 'n_tokens_mistral': 974, 'n_tokens_neox': 939, 'n_words': 181}