qenv/test/test.ts

34 lines
1.0 KiB
TypeScript
Raw Permalink Normal View History

import * as path from 'path';
import { tap, expect } from '@pushrocks/tapbundle';
import * as qenv from '../ts/index';
2016-06-20 08:45:43 +00:00
process.env['key1'] = 'original';
2016-06-20 08:45:43 +00:00
let testQenv: qenv.Qenv;
2016-06-20 08:45:43 +00:00
2017-05-12 15:56:51 +00:00
tap.test('should create a new class', async () => {
testQenv = new qenv.Qenv(
path.join(__dirname, 'assets'),
path.join(__dirname, 'assets'),
false
);
expect(testQenv).to.be.instanceof(qenv.Qenv);
});
2017-05-12 15:56:51 +00:00
tap.test('key1 should be not be overwritten since it is already present', async () => {
expect(testQenv.getEnvVarRequired('key1')).to.equal('original');
expect(testQenv.getEnvVarOnDemand('key1')).to.equal('original');
});
2016-06-20 08:45:43 +00:00
2017-05-12 15:56:51 +00:00
tap.test('key2 should be read from Yml', async () => {
expect(testQenv.getEnvVarRequired('key2')).to.equal('fromYml');
expect(testQenv.getEnvVarOnDemand('key2')).to.equal('fromYml');
});
2017-05-12 15:56:51 +00:00
tap.test('keyValueObjectArray should hold all retrieved values', async () => {
expect(testQenv.keyValueObject.key1).to.equal('original');
expect(testQenv.keyValueObject.key2).to.equal('fromYml');
});
2017-05-12 15:56:51 +00:00
tap.start();