Files
probot/test/plugins/stats.js
Jason Etcovitch 5d29945dd2 feat: /probot homepage (#279)
* 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
2017-10-17 09:35:58 -04:00

35 lines
1005 B
JavaScript

const request = require('supertest')
const express = require('express')
const nock = require('nock')
const plugin = require('../../lib/plugins/stats')
const helper = require('./helper')
describe('stats', function () {
let robot, server
beforeEach(async () => {
nock('https://api.github.com')
.defaultReplyHeaders({'Content-Type': 'application/json'})
.get('/app/installations?per_page=100').reply(200, [{id: 1, account: {login: 'testing'}}])
.get('/installation/repositories').reply(200, {repositories: [
{private: true, stargazers_count: 1},
{private: false, stargazers_count: 2}
]})
robot = helper.createRobot()
await plugin(robot)
server = express()
server.use(robot.router)
})
describe('GET /probot/stats', () => {
it('returns installation count and popular accounts', () => {
return request(server).get('/probot/stats')
.expect(200, {'installations': 1, 'popular': [{login: 'testing', stars: 2}]})
})
})
})