Files
probot/test/plugins/default.test.js
Brandon Keepers 2efa0b24b7 chore: Rename robot to app (#542)
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.
2018-06-01 17:45:23 -05:00

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')
})
})
})