now has a env vars feature
This commit is contained in:
41
test/test.ts
41
test/test.ts
@ -3,25 +3,36 @@ import * as beautylog from 'beautylog'
|
||||
|
||||
import { tap, expect } from 'tapbundle'
|
||||
|
||||
smartenv.printEnv()
|
||||
tap.test('should print env', async () => {
|
||||
smartenv.printEnv()
|
||||
}).catch(tap.threw)
|
||||
|
||||
// test smartenv.obs.add
|
||||
smartenv.obs.add('myTestObject',{key1:'Peter'})
|
||||
smartenv.obs.add('myTestObject',{key1:'Klaus'}) // now trying to add a second
|
||||
smartenv.printEnv()
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key1) // this should be Peter
|
||||
tap.test('obs add something', async () => {
|
||||
smartenv.obs.add('myTestObject', { key1: 'Peter' })
|
||||
smartenv.obs.add('myTestObject', { key1: 'Klaus' }) // now trying to add a second
|
||||
return expect(smartenv.obs.get('myTestObject').key1).to.equal('Peter')
|
||||
})
|
||||
|
||||
// test smartenv.obs.replace
|
||||
smartenv.obs.replace('myTestObject',{key1:'Klaus'})
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key1) // this should be Klaus
|
||||
tap.test('', async () => {
|
||||
smartenv.obs.replace('myTestObject', { key1: 'Klaus' })
|
||||
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
|
||||
})
|
||||
|
||||
// test smartenv.obs.merge
|
||||
smartenv.obs.merge('myTestObject',{key2:'Peter'})
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key1 + smartenv.obs.get('myTestObject').key2)
|
||||
// this should be KlausPeter
|
||||
tap.test('should merge things', async () => {
|
||||
smartenv.obs.merge('myTestObject', { key2: 'Peter' })
|
||||
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
|
||||
return expect(smartenv.obs.get('myTestObject').key2).to.equal('Peter')
|
||||
})
|
||||
|
||||
let key2 = 'hello'
|
||||
smartenv.obs.get('myTestObject').key2 = key2
|
||||
beautylog.log(smartenv.obs.get('myTestObject').key2)
|
||||
tap.test('set via get', async () => {
|
||||
smartenv.obs.get('myTestObject').key2 = 'hello'
|
||||
return expect(smartenv.obs.get('myTestObject').key2).to.equal('hello')
|
||||
})
|
||||
|
||||
beautylog.success('Success!')
|
||||
tap.test('should get regex env array', async () => {
|
||||
process.env.CUSTOM = 'some'
|
||||
let resultArray = await smartenv.getEnvVars(/CUSTOM/)
|
||||
return expect(resultArray).to.be.length(1)
|
||||
})
|
||||
|
Reference in New Issue
Block a user