mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-14 18:08:58 +08:00
* Add /probot route with tests * Add index route, write tests * Remove unused arg * Pass tests * Tweak HTML string and pkg require * Add static directory * Design welcome page * Rename to probot.html * Implement EJS * Remove duplicate load * Extract default homepage into plugin * Fix issue after merge conflict * Refactor app loading * Remove autoloading of plugings BREAKING CHANGE: `probot run` without any arguments will no longer autoload apps named `probot-*`. * Move setup * Look for `apps` key instead of `plugins` * Update simulate command * Simplify resolver * Remove unused routes variable * Move views to default path * Call probot.setup to properly initialize default apps * Simplify package loading * Specify extension * Add links to docs/slack * Remove stats link * Add helper to jest ignore * Fix ejs views error * Move a require to top of file * Remove unnecessary (and breaking) test
37 lines
944 B
JavaScript
37 lines
944 B
JavaScript
const request = require('supertest')
|
|
const createServer = require('../lib/server')
|
|
|
|
describe('server', function () {
|
|
let server
|
|
let webhook
|
|
|
|
beforeEach(() => {
|
|
webhook = jest.fn((req, res, next) => next())
|
|
server = createServer(webhook)
|
|
|
|
// Error handler to avoid printing logs
|
|
server.use(function (err, req, res, next) {
|
|
res.status(500).send(err.message)
|
|
})
|
|
})
|
|
|
|
describe('GET /ping', () => {
|
|
it('returns a 200 response', () => {
|
|
return request(server).get('/ping').expect(200, 'PONG')
|
|
})
|
|
})
|
|
|
|
describe('webhook handler', () => {
|
|
it('should 500 on a webhook error', () => {
|
|
webhook.mockImplementation((req, res, callback) => callback(new Error('webhook error')))
|
|
return request(server).post('/').expect(500)
|
|
})
|
|
})
|
|
|
|
describe('with an unknown url', () => {
|
|
it('responds with 404', () => {
|
|
return request(server).get('/lolnotfound').expect(404)
|
|
})
|
|
})
|
|
})
|