Files
Unciv/uncivbot/test/index.test.js
Yair Morgenstern a7548cd1e6 First version of Uncivbot, which deals with translation merging
When commenting "merge translations" in a PR, it:
- Creates a new 'translations' branch if it doesn't exist
- Creates a PR for the 'translations' branch if it doesn't exist
- Changes the PR's base to 'translations'
- Merges the PR, if it's mergable
2020-04-02 12:20:17 +03:00

59 lines
1.5 KiB
JavaScript

const nock = require('nock')
// Requiring our app implementation
const myProbotApp = require('..')
const { Probot } = require('probot')
// Requiring our fixtures
const payload = require('./fixtures/issues.opened')
const issueCreatedBody = { body: 'Thanks for opening this issue!' }
const fs = require('fs')
const path = require('path')
describe('My Probot app', () => {
let probot
let mockCert
beforeAll((done) => {
fs.readFile(path.join(__dirname, 'fixtures/mock-cert.pem'), (err, cert) => {
if (err) return done(err)
mockCert = cert
done()
})
})
beforeEach(() => {
nock.disableNetConnect()
probot = new Probot({ id: 123, cert: mockCert })
// Load our app into probot
probot.load(myProbotApp)
})
test('creates a comment when an issue is opened', async () => {
// Test that we correctly return a test token
nock('https://api.github.com')
.post('/app/installations/2/access_tokens')
.reply(200, { token: 'test' })
// Test that a comment is posted
nock('https://api.github.com')
.post('/repos/hiimbex/testing-things/issues/1/comments', (body) => {
expect(body).toMatchObject(issueCreatedBody)
return true
})
.reply(200)
// Receive a webhook event
await probot.receive({ name: 'issues', payload })
})
afterEach(() => {
nock.cleanAll()
nock.enableNetConnect()
})
})
// For more information about testing with Jest see:
// https://facebook.github.io/jest/
// For more information about testing with Nock see:
// https://github.com/nock/nock