本文整理匯總了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,
);
});