mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-15 02:18:58 +08:00
This replaces all internal references to "robot" with "app" or "Application". There should be no functional change in public APIs, but may cause some issues for anyone using internal APIs.
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
const request = require('supertest')
|
|
const express = require('express')
|
|
const plugin = require('../../src/plugins/default')
|
|
const helper = require('./helper')
|
|
|
|
describe('default plugin', function () {
|
|
let server, app
|
|
|
|
beforeEach(async () => {
|
|
app = helper.createApp(plugin)
|
|
server = express()
|
|
server.use(app.router)
|
|
})
|
|
|
|
describe('GET /probot', () => {
|
|
it('returns a 200 response', () => {
|
|
return request(server).get('/probot').expect(200)
|
|
})
|
|
|
|
describe('get info from package.json', () => {
|
|
let cwd
|
|
beforeEach(() => {
|
|
cwd = process.cwd()
|
|
})
|
|
|
|
it('returns the correct HTML with values', async () => {
|
|
const actual = await request(server).get('/probot').expect(200)
|
|
expect(actual.text).toMatch('Welcome to probot')
|
|
expect(actual.text).toMatch('A framework for building GitHub Apps')
|
|
expect(actual.text).toMatch(/v\d+\.\d+\.\d+/)
|
|
})
|
|
|
|
it('returns the correct HTML without values', async () => {
|
|
process.chdir(__dirname)
|
|
const actual = await request(server).get('/probot').expect(200)
|
|
expect(actual.text).toMatch('Welcome to your Probot App')
|
|
})
|
|
|
|
afterEach(() => {
|
|
process.chdir(cwd)
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('GET /', () => {
|
|
it('redirects to /probot', () => {
|
|
return request(server).get('/').expect(302).expect('location', '/probot')
|
|
})
|
|
})
|
|
})
|