Files
probot/test/plugins/default.test.js
Brandon Keepers 2530f3469a Merge remote-tracking branch 'origin/master' into typescript-init
* origin/master:
  Docs: Missing `break` statement in "Early exit" example (#538)
  chore: Commit version number, remove snapshot tests (#535)
  docs: Add docs on unauthenticated events and a log warning (#536)
  fix: Allow listening to `installation.deleted` event and other events
that don't include an installation id (#475)
2018-05-20 10:33:54 -05:00

55 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, robot
beforeEach(async () => {
robot = helper.createRobot()
await plugin(robot)
server = express()
server.use(robot.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')
})
})
})