本文整理汇总了TypeScript中src/util/fetch-mock.calls函数的典型用法代码示例。如果您正苦于以下问题:TypeScript calls函数的具体用法?TypeScript calls怎么用?TypeScript calls使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calls函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return p.then(() => {
assert.lengthOf(fetchMock.calls(expectedURL), 1);
assert.lengthOf(_.keys(state), 1);
assert.equal(state[missingKey].data, undefined);
assert.property(state[missingKey], "data");
assert.equal(state[missingKey].status, uidata.UIDataStatus.VALID);
assert.isNull(state[missingKey].error);
});
示例2:
return Promise.all([p1, p2]).then(() => {
// Assert that the server got the correct number of requests (2).
assert.lengthOf(fetchMock.calls("ts/query"), 3);
// Assert that the mock metrics state has 5 queries.
assert.lengthOf(_.keys(mockMetricsState.queries), 6);
_.each(mockMetricsState.queries, (q) => {
assert.isDefined(q.request);
assert.isUndefined(q.error);
assert.isDefined(q.data, "data not defined for query " + q.id);
});
// Assert that inFlight is 0.
assert.equal(mockMetricsState.inFlight, 0);
});
示例3: setTimeout
p.then(() => {
assert.lengthOf(fetchMock.calls(uidataPrefixMatcher), 1);
assert.lengthOf(_.keys(state), 2);
assert.equal(state[uiKey1].status, uidata.UIDataStatus.LOADING);
assert.equal(state[uiKey2].status, uidata.UIDataStatus.LOADING);
assert.isUndefined(state[uiKey1].data);
assert.isUndefined(state[uiKey2].data);
assert.notProperty(state[uiKey1], "data");
assert.notProperty(state[uiKey2], "data");
assert.isUndefined(state[uiKey1].error);
assert.isUndefined(state[uiKey2].error);
setTimeout(
() => {
assert.equal(state[uiKey1].status, uidata.UIDataStatus.LOAD_ERROR);
assert.equal(state[uiKey2].status, uidata.UIDataStatus.LOAD_ERROR);
assert.instanceOf(state[uiKey1].error, Error);
assert.instanceOf(state[uiKey2].error, Error);
done();
},
1000,
);
});