mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-04 00:59:41 +07:00
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
This commit is contained in:
58
uncivbot/test/index.test.js
Normal file
58
uncivbot/test/index.test.js
Normal file
@ -0,0 +1,58 @@
|
||||
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
|
Reference in New Issue
Block a user