本文整理汇总了TypeScript中fetch-mock/es5/client.mock函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mock函数的具体用法?TypeScript mock怎么用?TypeScript mock使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mock函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('rejects on 301', async () => {
fetchMock.mock('*', {
status: 301,
body: 'redirect',
});
const { uiSettingsApi } = setup();
await expect(uiSettingsApi.batchSet('foo', 'bar')).rejects.toThrowErrorMatchingSnapshot();
});
示例2: it
it('sends a single change immediately', () => {
fetchMock.mock('*', {
body: { settings: {} },
});
const { uiSettingsApi } = setup();
uiSettingsApi.batchSet('foo', 'bar');
expect(fetchMock.calls()).toMatchSnapshot('synchronous fetch');
});
示例3: it
it('Buffers are always clear of previously buffered changes', async () => {
fetchMock.mock('*', {
body: { settings: {} },
});
const { uiSettingsApi } = setup();
uiSettingsApi.batchSet('foo', 'bar');
uiSettingsApi.batchSet('bar', 'foo');
await uiSettingsApi.batchSet('bar', 'box');
expect(fetchMock.calls()).toMatchSnapshot('two requests, second only sends bar, not foo');
});