本文整理汇总了TypeScript中mock-http-server.on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript on函数的具体用法?TypeScript on怎么用?TypeScript on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了on函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
});
});
开发者ID:kevoree,项目名称:kevoree-js,代码行数:27,代码来源:auth.ts
示例2: it
it('retrieve specific dus', () => {
server.on({
method: 'GET',
path: '/api/namespaces/kevoree/tdefs/Ticker/3/specific-dus',
reply: {
status: 200,
body: JSON.stringify([
{
id: 0,
model: '{}',
namespace: 'kevoree',
tdefName: 'Ticker',
tdefVersion: 3,
name: 'kevoree-comp-ticker',
version: '3.1.0-alpha',
platform: 'js',
},
{
id: 1,
model: '{}',
namespace: 'kevoree',
tdefName: 'Ticker',
tdefVersion: 3,
name: 'kevoree-comp-ticker',
version: '3.0.0',
platform: 'java',
},
{
id: 2,
model: '{}',
namespace: 'kevoree',
tdefName: 'Ticker',
tdefVersion: 3,
name: 'kevoree-comp-ticker',
version: '5.4.0-SNAPSHOT',
platform: 'dotnet',
},
]),
},
});
const filters = {
js: '3.1.0-alpha',
dotnet: 'latest',
};
return du.getSpecificByNamespaceAndTdefNameAndTdefVersion('kevoree', 'Ticker', 3, filters)
.then((dus) => {
assert.equal(dus.length, 3);
const js = dus.find((deployUnit) => deployUnit.platform === 'js');
assert.isNotNull(js);
assert.equal(js!.version, filters.js);
const java = dus.find((deployUnit) => deployUnit.platform === 'java');
assert.isNotNull(java);
assert.equal(java!.version, '3.0.0');
const dotnet = dus.find((deployUnit) => deployUnit.platform === 'dotnet');
assert.isNotNull(dotnet);
assert.equal(dotnet!.version, '5.4.0-SNAPSHOT');
});
});
开发者ID:kevoree,项目名称:kevoree-js,代码行数:60,代码来源:dus.ts
示例3: it
it('create a new tdef', () => {
const expectedTdef = {
id: 4,
namespace: 'kevoree',
name: 'Foo',
version: 1,
model: JSON.stringify({
class: 'org.kevoree.Component@Foo',
name: 'Foo',
version: 1,
potato: 'foo',
}),
};
server.on({
method: 'POST',
path: '/api/namespaces/kevoree/tdefs',
reply: {
status: 201,
body: JSON.stringify(expectedTdef),
},
});
logUserIn();
return tdef.create('kevoree', expectedTdef)
.then((typeDef) => {
assert.equal(typeDef.id, expectedTdef.id);
assert.equal(typeDef.name, expectedTdef.name);
assert.equal(typeDef.version, expectedTdef.version);
assert.equal(typeDef.model, expectedTdef.model);
assert.equal(typeDef.namespace, expectedTdef.namespace);
});
});
开发者ID:kevoree,项目名称:kevoree-js,代码行数:34,代码来源:tdefs.ts
示例4: it
it('delete a namespace', () => {
const expectedNs = { name: 'newnamespace', owner: 'kevoree' };
server.on({
method: 'DELETE',
path: '/api/namespaces/newnamespace',
reply: {
status: 200,
body: JSON.stringify(expectedNs),
},
});
logUserIn();
return namespace.delete('newnamespace');
});
开发者ID:kevoree,项目名称:kevoree-js,代码行数:16,代码来源:namespaces.ts
注:本文中的mock-http-server.on函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论