mirror of
https://github.com/Permissionless-Software-Foundation/x402-base-facilitator.git
synced 2026-09-21 16:52:01 -07:00
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
/*
|
|
Unit tests for the config directory
|
|
*/
|
|
|
|
import { assert } from 'chai'
|
|
|
|
let currentEnv
|
|
|
|
describe('#config', () => {
|
|
before(() => {
|
|
// Backup the current environment setting.
|
|
currentEnv = process.env.SVC_ENV
|
|
})
|
|
|
|
after(() => {
|
|
// Restore the environment setting before starting these tests.
|
|
process.env.SVC_ENV = currentEnv
|
|
})
|
|
|
|
it('Should return development environment config by default', async () => {
|
|
const importedConfig = await import('../../../config/index.js')
|
|
const config = importedConfig.default
|
|
// console.log('config: ', config)
|
|
|
|
assert.equal(config.env, 'dev')
|
|
})
|
|
|
|
it('Should return test environment config', async () => {
|
|
// Hack to dynamically import a library multiple times:
|
|
// https://github.com/denoland/deno/issues/6946
|
|
|
|
process.env.SVC_ENV = 'test'
|
|
|
|
const importedConfig2 = await import('../../../config/index.js?foo=bar1')
|
|
const config = importedConfig2.default
|
|
// console.log('config: ', config)
|
|
|
|
assert.equal(config.env, 'test')
|
|
})
|
|
|
|
it('Should return test environment config', async () => {
|
|
process.env.SVC_ENV = 'prod'
|
|
|
|
const importedConfig3 = await import('../../../config/index.js?foo=bar2')
|
|
const config = importedConfig3.default
|
|
// console.log('config: ', config)
|
|
|
|
assert.equal(config.env, 'prod')
|
|
})
|
|
})
|