This is a bit of sugar that reduces the boilerplate for creating testers in what I expect will become the standard case: a service in `foo/foo-thing.service.js` with its tests in `foo/foo-thing.tester.js`. This makes a small stylistic change, which is to name the service by its CamelCase class name rather than an invented snake-case ID. Whereas before the name was specified in `class FooThing extends Base[Json]Service` and a second time in the tester, it now only needs to be specified once.
34 lines
818 B
JavaScript
34 lines
818 B
JavaScript
'use strict'
|
|
|
|
const Joi = require('joi')
|
|
const createServiceTester = require('../create-service-tester')
|
|
|
|
const t = createServiceTester()
|
|
module.exports = t
|
|
|
|
const isTypeDefinition = Joi.string().regex(
|
|
/^((Flow|TypeScript)|(Flow \| TypeScript))$/
|
|
)
|
|
|
|
t.create('types (from dev dependencies + files)')
|
|
.get('/chalk.json')
|
|
.expectJSONTypes(
|
|
Joi.object().keys({ name: 'types', value: isTypeDefinition })
|
|
)
|
|
|
|
t.create('types (from files)')
|
|
.get('/form-data-entries.json')
|
|
.expectJSONTypes(
|
|
Joi.object().keys({ name: 'types', value: isTypeDefinition })
|
|
)
|
|
|
|
t.create('types (from types key)')
|
|
.get('/left-pad.json')
|
|
.expectJSONTypes(
|
|
Joi.object().keys({ name: 'types', value: isTypeDefinition })
|
|
)
|
|
|
|
t.create('no types')
|
|
.get('/link-into.json')
|
|
.expectJSON({ name: 'types', value: 'none' })
|