mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-14 09:58:57 +08:00
Reverts https://github.com/probot/probot/pull/397/files fix(package): update @octokit/rest to version 15.1.7 Name the Logger export Make object types optional Merge branch 'master' into typescript-init Bump deps for standard and octokit Bump ts dependency Made the option optional. 😉
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
const request = require('supertest')
|
|
const express = require('express')
|
|
const nock = require('nock')
|
|
const plugin = require('../../src/plugins/stats')
|
|
|
|
const helper = require('./helper')
|
|
|
|
describe('stats', function () {
|
|
let robot, server
|
|
|
|
beforeEach(() => {
|
|
// Clean up env variable
|
|
delete process.env.DISABLE_STATS
|
|
})
|
|
|
|
describe('GET /probot/stats', () => {
|
|
beforeEach(async () => {
|
|
nock('https://api.github.com')
|
|
.defaultReplyHeaders({'Content-Type': 'application/json'})
|
|
.post('/installations/1/access_tokens').reply(200, {token: 'test'})
|
|
.get('/app/installations?per_page=100').reply(200, [{id: 1, account: {login: 'testing'}}])
|
|
.get('/installation/repositories?per_page=100').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)
|
|
})
|
|
|
|
it('returns installation count and popular accounts', () => {
|
|
return request(server).get('/probot/stats')
|
|
.expect(200, {'installations': 1, 'popular': [{login: 'testing', stars: 2}]})
|
|
})
|
|
})
|
|
|
|
describe('can be disabled', () => {
|
|
beforeEach(async () => {
|
|
process.env.DISABLE_STATS = 'true'
|
|
|
|
robot = helper.createRobot()
|
|
|
|
await plugin(robot)
|
|
|
|
server = express()
|
|
server.use(robot.router)
|
|
})
|
|
|
|
it('/probot/stats returns 404', () => {
|
|
return request(server).get('/probot/stats').expect(404)
|
|
})
|
|
})
|
|
})
|