提交 d104b583 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

support puppetInstance() to save/load instance of puppet

上级 b79850e4
......@@ -71,4 +71,14 @@ function isWechatyDocker() {
return true
}
/**
* 5. live setting
*/
Config.puppetInstance = function(instance) {
if (typeof instance !== 'undefined') { // null is valid here
Config._puppetInstance = instance
}
return Config._puppetInstance
}
module.exports = Config.default = Config.Config = Config
......@@ -35,12 +35,20 @@ test('Config methods', t => {
Config.validApiHost(apihost)
})
}, 'should not row for right apihost')
ERR_APIHOSTS.forEach(apihost => {
ERR_APIHOSTS.forEach(apihost => {
t.throws(_ => {
Config.validApiHost(apihost)
})
}, 'should throw for error apihost')
t.true('isDocker' in Config, 'should identify docker env by `isDocker`')
})
})
\ No newline at end of file
test('Config puppetInstance', t => {
let instance = Config.puppetInstance()
t.falsy(instance, 'should empty initialy')
t.truthy(Config.puppetInstance({}), 'should return instance in arg')
t.truthy(Config.puppetInstance(), 'should return instance after set')
t.falsy(Config.puppetInstance(null), 'should return null after set to null')
t.falsy(instance, 'should empty after set to null')
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册