本文整理汇总了TypeScript中tiny-conf.set函数的典型用法代码示例。如果您正苦于以下问题:TypeScript set函数的具体用法?TypeScript set怎么用?TypeScript set使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('auth.ensureLogin() should try to refresh token if expired', () => {
const expectedAuth = {
access_token: 'new-foo',
refresh_token: 'new-bar',
expires_in: 3600,
};
server.on({
method: 'POST',
path: '/oauth/token',
reply: {
status: 200,
body: JSON.stringify(expectedAuth),
},
});
// define user data as expired
config.set('user.expires_at', Date.now() - (1000 * 60 * 10)); // 10min old
return auth.ensureLogin()
.then(() => {
const user: IConfigUser = config.get('user');
assert.equal(user.access_token, expectedAuth.access_token);
assert.equal(user.refresh_token, expectedAuth.refresh_token);
assert.isAtLeast(user.expires_at!, Date.now());
});
});
示例2: default
export default () => {
conf.set({
registry: {
host: 'localhost',
port: 8080,
ssl: false,
oauth: {
client_id: 'kevoree_registryapp',
client_secret: 'kevoree_registryapp_secret',
},
},
user: {
login: 'kevoree',
},
});
};
示例3: afterEach
afterEach('reset conf', () => {
conf.set({
registry: {
host: 'localhost',
port: 8080,
ssl: false,
oauth: {
client_id: 'kevoree_registryapp',
client_secret: 'kevoree_registryapp_secret',
},
},
user: {
login: 'kevoree',
password: 'kevoree',
},
});
});
示例4: logUserIn
export function logUserIn() {
config.set('user.access_token', 'foo');
config.set('user.expires_at', Date.now() + (1000 * 60 * 10)); // 10 min
}
示例5: it
it('token() should return current user token', () => {
conf.set('user.access_token', 'foo');
conf.set('user.expires_at', Date.now() + 1000);
assert.equal(token(), 'foo');
});
示例6: before
before('', () => {
conf.set('registry.host', 'unknown-host.fail');
});