Files
shields/services/node/node.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

50 lines
1.5 KiB
JavaScript

'use strict'
const { expect } = require('chai')
const Joi = require('joi')
const { Range } = require('semver')
const t = (module.exports = require('../tester').createServiceTester())
function expectSemverRange(value) {
expect(() => new Range(value)).not.to.throw()
}
t.create('gets the node version of passport')
.get('/passport.json')
.expectJSONTypes(Joi.object({ name: 'node' }).unknown())
.afterJSON(json => {
expectSemverRange(json.value)
})
t.create('gets the node version of @stdlib/stdlib')
.get('/@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('/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('/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('/@cycle/core/canary.json')
.expectJSONTypes(Joi.object({ name: 'node@canary' }).unknown())
.afterJSON(json => {
expectSemverRange(json.value)
})
t.create('invalid package name')
.get('/frodo-is-not-a-package.json')
.expectJSON({ name: 'node', value: 'package not found' })