mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Add support for passing in custom env file to nconf.
This commit is contained in:
@@ -3,29 +3,39 @@ import setupNconf from '../../../../../website/src/libs/api-v3/setupNconf';
|
||||
import nconf from 'nconf';
|
||||
|
||||
describe('setupNconf', () => {
|
||||
before(() => {
|
||||
sandbox.spy(nconf, 'argv');
|
||||
sandbox.spy(nconf, 'env');
|
||||
sandbox.spy(nconf, 'file');
|
||||
|
||||
setupNconf();
|
||||
beforeEach(() => {
|
||||
sandbox.stub(nconf, 'argv').returnsThis();
|
||||
sandbox.stub(nconf, 'env').returnsThis();
|
||||
sandbox.stub(nconf, 'file').returnsThis();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterEach(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('sets up nconf', () => {
|
||||
setupNconf();
|
||||
|
||||
expect(nconf.argv).to.be.calledOnce;
|
||||
expect(nconf.env).to.be.calledOnce;
|
||||
expect(nconf.file).to.be.calledOnce;
|
||||
expect(nconf.file).to.be.calledWithMatch('user', /\/config.json$/);
|
||||
});
|
||||
|
||||
it('sets IS_PROD variable', () => {
|
||||
setupNconf();
|
||||
expect(nconf.get('IS_PROD')).to.exist;
|
||||
});
|
||||
|
||||
it('sets IS_DEV variable', () => {
|
||||
setupNconf();
|
||||
expect(nconf.get('IS_DEV')).to.exist;
|
||||
});
|
||||
|
||||
it('allows a custom config.json file to be passed in', () => {
|
||||
setupNconf('customfile.json');
|
||||
|
||||
expect(nconf.file).to.be.calledOnce;
|
||||
expect(nconf.file).to.be.calledWithMatch('user', 'customfile.json');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user