2017-01-21 10:51:30 +00:00
|
|
|
import * as path from 'path'
|
2017-05-12 15:56:51 +00:00
|
|
|
import { tap, expect } from 'tapbundle'
|
|
|
|
import * as qenv from '../dist/index'
|
2016-06-20 08:45:43 +00:00
|
|
|
|
2017-05-12 15:56:51 +00:00
|
|
|
process.env[ 'key1' ] = 'original'
|
2016-06-20 08:45:43 +00:00
|
|
|
|
2017-05-12 15:56:51 +00:00
|
|
|
let qenvTestObject: 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 () => {
|
|
|
|
qenvTestObject = new qenv.Qenv(path.join(__dirname, 'assets'), path.join(__dirname, 'assets'), false)
|
|
|
|
expect(qenvTestObject).to.be.instanceof(qenv.Qenv)
|
|
|
|
})
|
|
|
|
|
|
|
|
tap.test('key1 should be not be overwritten since it is already present', async () => {
|
|
|
|
expect(process.env.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(process.env.key2).to.equal('fromYml')
|
2017-01-21 10:57:04 +00:00
|
|
|
})
|
2017-05-12 15:56:51 +00:00
|
|
|
|
|
|
|
tap.test('keyValueObjectArray should hold all retrieved values', async () => {
|
|
|
|
expect(qenvTestObject.keyValueObjectArray[ 0 ].value).to.equal('original')
|
|
|
|
expect(qenvTestObject.keyValueObjectArray[ 1 ].value).to.equal('fromYml')
|
|
|
|
})
|
|
|
|
|
|
|
|
tap.start()
|