Files
shields/services/sourcegraph/sourcegraph.tester.js
Paul Melnikow 4bd16f93e8 Sort imports and requires (#3056)
This will definitely save time, and ensure more uniformity.

It moves the `createServiceTester()` calls to a different place from where I'd like them, though I'm happy to have them checked by the linter.

Closes #2701
2019-02-21 22:14:40 -05:00

26 lines
790 B
JavaScript

'use strict'
const Joi = require('joi')
const { withRegex } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
// Matches API responses such as "0 projects", "1 projects", "182 projects", "14.0k projects".
// There may be other cases not covered by this regex, but hopefully the tested projects won't vary much.
const projectsCount = withRegex(/^[0-9]*(\.[0-9]k)?\sprojects$/)
t.create('project usage count')
.get('/github.com/theupdateframework/notary.json')
.expectJSONTypes(
Joi.object().keys({
name: 'used by',
value: projectsCount,
})
)
t.create('project without any available information')
.get('/github.com/PyvesB/EmptyRepo.json')
.expectJSON({
name: 'used by',
value: '0 projects',
})