streamline package
This commit is contained in:
38
test/test.ts
38
test/test.ts
@ -1,38 +1,14 @@
|
||||
import * as smartenv from '../dist/index.js'
|
||||
import * as beautylog from 'beautylog'
|
||||
|
||||
import { tap, expect } from 'tapbundle'
|
||||
import * as smartenv from '../dist/index'
|
||||
|
||||
let testEnv: smartenv.Smartenv
|
||||
|
||||
tap.test('should print env', async () => {
|
||||
smartenv.printEnv()
|
||||
}).catch(tap.threw)
|
||||
|
||||
// test smartenv.obs.add
|
||||
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')
|
||||
testEnv = new smartenv.Smartenv()
|
||||
})
|
||||
|
||||
// test smartenv.obs.replace
|
||||
tap.test('', async () => {
|
||||
smartenv.obs.replace('myTestObject', { key1: 'Klaus' })
|
||||
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
|
||||
tap.test('should print a overview to console', async () => {
|
||||
testEnv.printEnv()
|
||||
})
|
||||
|
||||
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')
|
||||
})
|
||||
|
||||
tap.test('set via get', async () => {
|
||||
smartenv.obs.get('myTestObject').key2 = 'hello'
|
||||
return expect(smartenv.obs.get('myTestObject').key2).to.equal('hello')
|
||||
})
|
||||
|
||||
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)
|
||||
})
|
||||
tap.start()
|
||||
|
Reference in New Issue
Block a user