本文整理汇总了TypeScript中fetch-mock.calls函数的典型用法代码示例。如果您正苦于以下问题:TypeScript calls函数的具体用法?TypeScript calls怎么用?TypeScript calls使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calls函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createXhr
return createXhr().ajax('/some/url', { pollDelay: 0 }).then((r) => {
expect(r.response.status).toBe(200);
expect(fetchMock.calls('/some/url').length).toBe(1);
expect(fetchMock.calls('/other/url').length).toBe(1);
expect(fetchMock.calls('/last/url').length).toBe(1);
expect(r.getData()).toBe('Poll result with redirects');
});
示例2: it
it('buffers changes while first request is in progress, sends buffered changes after first request completes', async () => {
fetchMock.mock('*', {
body: { settings: {} },
});
const { uiSettingsApi } = setup();
uiSettingsApi.batchSet('foo', 'bar');
const finalPromise = uiSettingsApi.batchSet('box', 'bar');
expect(fetchMock.calls()).toMatchSnapshot('initial, only one request');
await finalPromise;
expect(fetchMock.calls()).toMatchSnapshot('final, includes both requests');
});
示例3: expect
const complete = () => {
count++;
if (count === 4) {
try {
const lawlCalls = fetchMock.calls('begin:lawl');
expect(lawlCalls.length).toBe(1);
const roflCalls = fetchMock.calls('begin:rofl');
expect(roflCalls.length).toBe(1);
done();
} catch (e) {
done.fail(e);
}
}
};
示例4:
return p.then(() => {
assert.lengthOf(fetchMock.calls(expectedURL), 1);
assert.lengthOf(_.keys(state.data), 1);
assert.deepEqual(state.data[missingKey], undefined);
assert.isNull(state.error);
assert.equal(state.inFlight, 0);
});
示例5:
fetchMock.get('/some/url', (url) => {
if (fetchMock.calls(url).length <= 2) {
return 202;
}
return { status: 200, body: 'Poll result' };
});
示例6: it
it('should not make any network calls in uriCollector callback', function() {
this.api.batch(
batchApi => [
batchApi.copy('foo', 'bar', {name: 'Copy of bar'}),
batchApi.count('USER', {}),
batchApi.create('baz', {
foo: 'bar'
}, ['*', 'zzz:*']),
batchApi.edit('PROJ', 'foobar', {
name: 'api test 2'
}),
batchApi.execute('foo', 'bar', 'baz'),
batchApi.get('foo', 'bar'),
batchApi.metadata('TASK', ['collections']),
batchApi.namedQuery('foo', 'action'),
batchApi.remove('foo', 'objID'),
batchApi.report('task', {
'status_GroupBy': true
}),
batchApi.search('role', {
'status_GroupBy': true
})
],
false
)
should(fetchMock.calls().length).equal(1)
})
示例7: it
it('should stringify JSON data for GDC backend', () => {
fetchMock.get('/some/url', { status: 200 });
createXhr().ajax('/some/url', { body: { foo: 'bar' } });
const request = fetchMock.calls().matched[0][1] as RequestInit;
expect(request.body).toBe('{"foo":"bar"}');
});
示例8:
return p.then(() => {
assert.lengthOf(fetchMock.calls("/_admin/v1/uidata"), 1);
assert.lengthOf(_.keys(state.data), 2);
assert.equal(state.data[uiKey1], uiObj1);
assert.equal(state.data[uiKey2], uiObj2);
assert.isNull(state.error);
assert.equal(state.inFlight, 0);
});