test.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const assume = require('assume');
  2. const env = require('./');
  3. describe('env-variable', function () {
  4. it('merges with process.env as we are running on node', function () {
  5. process.env.TESTING_ENVS = 'wat';
  6. const data = env();
  7. assume(data.TESTING_ENVS).equals('wat');
  8. assume(data.foo).is.a('undefined');
  9. const merged = env({ foo: 'bar' });
  10. assume(merged.TESTING_ENVS).equals('wat');
  11. assume(merged.foo).equals('bar');
  12. });
  13. it('lowercases keys', function () {
  14. process.env.UPPERCASE = 'does NOT touch VALUES';
  15. const data = env({ FOO: 'bar' });
  16. assume(data.UPPERCASE).equals('does NOT touch VALUES');
  17. assume(data.uppercase).equals('does NOT touch VALUES');
  18. assume(data.FOO).equals('bar');
  19. assume(data.foo).equals('bar');
  20. });
  21. describe('#merge', function () {
  22. it('merges objects', function () {
  23. const data = {};
  24. env.merge(data, { foo: 'bar' });
  25. assume(data).deep.equals({ foo: 'bar' });
  26. });
  27. });
  28. describe('#parse', function () {
  29. it('parses basic query strings', function () {
  30. const data = env.parse('foo=bar');
  31. assume(data).is.a('object');
  32. assume(data).deep.equals({ foo: 'bar' });
  33. });
  34. });
  35. });