You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
742 B
39 lines
742 B
3 years ago
|
'use strict'
|
||
|
|
||
|
const { test } = require('tap')
|
||
|
const envSchema = require('../index')
|
||
|
|
||
|
test('no globals', t => {
|
||
|
t.plan(2)
|
||
|
|
||
|
const options = {
|
||
|
confKey: 'secrets',
|
||
|
data: {
|
||
|
MONGO_URL: 'good'
|
||
|
},
|
||
|
schema: {
|
||
|
$id: 'schema:dotenv',
|
||
|
type: 'object',
|
||
|
required: ['MONGO_URL'],
|
||
|
properties: {
|
||
|
PORT: {
|
||
|
type: 'integer',
|
||
|
default: 3000
|
||
|
},
|
||
|
MONGO_URL: {
|
||
|
type: 'string'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
{
|
||
|
const conf = envSchema(JSON.parse(JSON.stringify(options)))
|
||
|
t.strictSame(conf, { MONGO_URL: 'good', PORT: 3000 })
|
||
|
}
|
||
|
{
|
||
|
const conf = envSchema(JSON.parse(JSON.stringify(options)))
|
||
|
t.strictSame(conf, { MONGO_URL: 'good', PORT: 3000 })
|
||
|
}
|
||
|
})
|