Files
shields/services/node/node.tester.js
Paul Melnikow 7a664ca3e8 Run prettier (#1866)
Merging this separately so the commit with the tooling change is readable. This is a follow-on to #1167 which turned prettier on.
2018-08-08 17:57:14 -04:00

53 lines
1.5 KiB
JavaScript

'use strict'
const { expect } = require('chai')
const Joi = require('joi')
const ServiceTester = require('../service-tester')
const { Range } = require('semver')
const t = new ServiceTester({ id: 'node', title: 'Node' })
module.exports = t
function expectSemverRange(value) {
expect(() => new Range(value)).not.to.throw()
}
t.create('gets the node version of passport')
.get('/v/passport.json')
.expectJSONTypes(Joi.object({ name: 'node' }).unknown())
.afterJSON(json => {
expectSemverRange(json.value)
})
t.create('gets the node version of @stdlib/stdlib')
.get('/v/@stdlib/stdlib.json')
.expectJSONTypes(Joi.object({ name: 'node' }).unknown())
.afterJSON(json => {
expectSemverRange(json.value)
})
t.create("gets the tagged release's node version version of ionic")
.get('/v/ionic/next.json')
.expectJSONTypes(Joi.object({ name: 'node@next' }).unknown())
.afterJSON(json => {
expectSemverRange(json.value)
})
t.create('gets the node version of passport from a custom registry')
.get('/v/passport.json?registry_uri=https://registry.npmjs.com')
.expectJSONTypes(Joi.object({ name: 'node' }).unknown())
.afterJSON(json => {
expectSemverRange(json.value)
})
t.create("gets the tagged release's node version of @cycle/core")
.get('/v/@cycle/core/canary.json')
.expectJSONTypes(Joi.object({ name: 'node@canary' }).unknown())
.afterJSON(json => {
expectSemverRange(json.value)
})
t.create('invalid package name')
.get('/v/frodo-is-not-a-package.json')
.expectJSON({ name: 'node', value: 'package not found' })