-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
59 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
HELLO=HELLO | ||
HELLO=WORLD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"hello": "HELLO" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"hello": "hello from config", | ||
"hi": "hi from config" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
'use strict'; | ||
|
||
exports.hello = function hello() { | ||
return process.env.HELLO; | ||
const config = require('config'); | ||
|
||
|
||
exports.fromEnv = { | ||
HELLO() { | ||
return process.env.HELLO; | ||
} | ||
}; | ||
|
||
exports.fromConfig = { | ||
hi() { | ||
return config.get('hi'); | ||
}, | ||
|
||
hello() { | ||
return config.get('hello'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
'use strict'; | ||
|
||
const { expect } = require('chai'); | ||
const { hello } = require('../src'); | ||
const { fromConfig, fromEnv } = require('../src'); | ||
|
||
describe('Importing The index module', function () { | ||
it('should be a function', function () { | ||
expect(hello).to.be.a('function'); | ||
|
||
describe('Checking Environment Variable `HELLO`', function () { | ||
it('should return value from environment variable', function () { | ||
expect(fromEnv.HELLO()).to.be.equal('WORLD'); | ||
}); | ||
|
||
it('should return value from config file', function () { | ||
expect(fromConfig.hi()).to.be.equal('hi from config'); | ||
}); | ||
|
||
it('should return `HELLO` string from env', function () { | ||
expect(hello()).to.be.equal('HELLO'); | ||
it('should return value from custom environment variable', function () { | ||
expect(fromConfig.hello()).to.be.equal('WORLD'); | ||
}); | ||
}); |