当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fetch-mock.calls函数代码示例

本文整理汇总了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');
 });
开发者ID:gooddata,项目名称:gooddata-js,代码行数:7,代码来源:xhr.test.ts

示例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');
  });
开发者ID:austec-automation,项目名称:kibana,代码行数:14,代码来源:ui_settings_api.test.ts

示例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);
     }
   }
 };
开发者ID:SET001,项目名称:apollo-link,代码行数:14,代码来源:batchHttpLink.ts

示例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);
 });
开发者ID:CubeLite,项目名称:cockroach,代码行数:7,代码来源:uiData.spec.ts

示例5:

            fetchMock.get('/some/url', (url) => {
                if (fetchMock.calls(url).length <= 2) {
                    return 202;
                }

                return { status: 200, body: 'Poll result' };
            });
开发者ID:gooddata,项目名称:gooddata-js,代码行数:7,代码来源:xhr.test.ts

示例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)
	})
开发者ID:Workfront,项目名称:workfront-api,代码行数:27,代码来源:batch.spec.ts

示例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"}');
        });
开发者ID:gooddata,项目名称:gooddata-js,代码行数:8,代码来源:xhr.test.ts

示例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);
 });
开发者ID:WillHaack,项目名称:cockroach,代码行数:8,代码来源:uiData.spec.ts


注:本文中的fetch-mock.calls函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。