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


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

本文整理汇总了TypeScript中fetch-mock.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

 test('brokenProofs', (t) => {
   FetchMock.get(`${naval.facebook.url}b`, naval.facebook.body)
   FetchMock.get(`${naval.github.url}b/raw`, naval.github.body)
   FetchMock.get(`${naval.twitter.url}b`, { body: '', status: 400 })
   t.plan(2)
   validateProofs({ account: navalAccounts }, undefined, 'naval.id')
     .then((proofs) => {
       t.equal(proofs.length, 3)
       t.equal(proofs.filter(x => x.valid).length, 2)
       FetchMock.restore()
     })
 })
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:12,代码来源:unitTestsProofs.ts

示例2: it

        it('should folow multiple redirects', () => {
            fetchMock.get('/some/url', { status: 202, headers: { Location: '/other/url' } });
            fetchMock.get('/other/url', { status: 202, headers: { Location: '/last/url' } });
            fetchMock.get('/last/url', { status: 200, body: 'Poll result with redirects' });

            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,代码行数:13,代码来源:xhr.test.ts

示例3: test

test('Succeeding project creation with remote schema file', async t => {
  const name = 'MyProject'
  const schemaUrl = 'https://graphqlbin/project.graphql'

  // configure HTTP mocks
  fetchMock.post(systemAPIEndpoint, JSON.parse(mockedCreateProjectResponse))

  const schema = simpleTwitterSchema
  fetchMock.get(schemaUrl, schema)

  // create dummy project data
  const props = {name, schemaUrl}

  // prepare environment
  const env = testEnvironment({})
  env.resolver.write(graphcoolConfigFilePath, '{"token": "abcdefgh"}')

  env.out.prefix((t as any)._test.title, `$ graphcool init -s ${schemaUrl} -n ${name}`)

  await t.notThrows(
    initCommand(props, env)
  )

  const expectedProjectFileContent = mockProjectFile1
  t.is(env.resolver.read(graphcoolProjectFileName), expectedProjectFileContent)
  t.is(readProjectIdFromProjectFile(env.resolver, graphcoolProjectFileName), 'abcdefghijklmn')
  t.is(readVersionFromProjectFile(env.resolver, graphcoolProjectFileName), '1')
})
开发者ID:sadeeqaji,项目名称:graphcool-cli,代码行数:28,代码来源:init.test.ts

示例4: it

 it('should use supplied Content-Type', async () => {
   fetchMock.get('*', {});
   await kfetch({ pathname: 'my/path', headers: { 'Content-Type': 'CustomContentType' } });
   expect(fetchMock.lastOptions('*').headers).toMatchObject({
     'Content-Type': 'CustomContentType',
   });
 });
开发者ID:gingerwizard,项目名称:kibana,代码行数:7,代码来源:kfetch.test.ts

示例5: test

test('Succeeding auth without token', async t => {

  // configure HTTP mocks
  fetchMock.post(`${authEndpoint}/create`, {})
  fetchMock.get(`${authEndpoint}/*`, {
    authToken: testToken
  })
  fetchMock.post(`${systemAPIEndpoint}`, {
    data: {
      viewer: {
        user: {
          id: 'abcdefghik'
        }
      }
    }
  })

  // configure auth dependencies
  const env = testEnvironment({})
  const authServer = new TestAuthServer()

  env.out.prefix((t as any)._test.title, '$ graphcool auth')

  // authenticate
  await t.notThrows(
    authCommand({}, env, authServer)
  )

  // verify result
  const {token} = JSON.parse(env.resolver.read(graphcoolConfigFilePath))
  t.is(token, testToken)
})
开发者ID:sadeeqaji,项目名称:graphcool-cli,代码行数:32,代码来源:auth.test.ts

示例6: it

 it('gets orderbook with default page options when none are provided', async () => {
     const urlWithQuery = `${url}?baseTokenAddress=${
         request.baseTokenAddress
     }&page=1&per_page=100&quoteTokenAddress=${request.quoteTokenAddress}`;
     fetchMock.get(urlWithQuery, orderbookJSON);
     const orderbook = await relayerClient.getOrderbookAsync(request);
     expect(orderbook).to.be.deep.equal(orderbookResponse);
 });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:8,代码来源:http_client_test.ts

示例7: beforeEach

 beforeEach(async () => {
   fetchMock.get('*', { status: 404, body: { foo: 'bar' } });
   try {
     await kfetch({ pathname: 'my/path' });
   } catch (e) {
     error = e;
   }
 });
开发者ID:gingerwizard,项目名称:kibana,代码行数:8,代码来源:kfetch.test.ts


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