當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript nock.Scope類代碼示例

本文整理匯總了TypeScript中nock.Scope的典型用法代碼示例。如果您正苦於以下問題:TypeScript Scope類的具體用法?TypeScript Scope怎麽用?TypeScript Scope使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Scope類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: put

  export function put(nock: Scope, buildpacks?: Array<string>, registry?: Map<string, {url: string, name: string}>) {
    let updates: Array<{buildpack: string}> = []
    let response: Array<{
      buildpack: {
        url: string,
        name?: string,
      },
      ordinal: number,
    }> = []

    if (buildpacks) {
      updates = buildpacks.map(b => {
        return {buildpack: b}
      })
      response = buildpacks.map((b, index) => {
        let buildpack: {url: string, name?: string} = {url: b}

        if (registry) {
          buildpack = registry.get(b) || {url: b}
        }

        return {buildpack, ordinal: index}
      })
    }

    nock
      .put('/apps/example/buildpack-installations', {updates})
      .reply(200, response)
  }
開發者ID:jimmyurl,項目名稱:cli,代碼行數:29,代碼來源:buildpack-installations-stub.ts

示例2:

 .nock('https://api.heroku.com', (api: Scope) => {
   Stubber.get(api, ['https://github.com/heroku/heroku-buildpack-ruby'])
   Stubber.put(api)
   api
     .get('/apps/example/config-vars')
     .reply(200, {})
 })
開發者ID:jimmyurl,項目名稱:cli,代碼行數:7,代碼來源:remove.test.ts

示例3: get

  export function get(nock: Scope, buildpacks?: Array<string | {url: string, name: string}>) {
    let response: any

    if (buildpacks && buildpacks.length > 0) {
      if (typeof(buildpacks[0]) === 'string') {
        response = buildpacks.map((b, i) => {
          return {
            buildpack: {url: b},
            ordinal: i,
          }
        })
      } else {
        response = buildpacks.map((b, i) => {
          return {
            buildpack: b,
            ordinal: i,
          }
        })
      }
    } else {
      response = []
    }

    nock
      .get('/apps/example/buildpack-installations')
      .reply(200, response)
  }
開發者ID:jimmyurl,項目名稱:cli,代碼行數:27,代碼來源:buildpack-installations-stub.ts

示例4:

 .nock('https://buildpack-registry.heroku.com', (api: Scope) => {
   api
     .get('/buildpacks/heroku%2Fruby/revisions')
     .reply(200, [
       Fixture.revision({
         release: 138,
       })
     ])
 })
開發者ID:jimmyurl,項目名稱:cli,代碼行數:9,代碼來源:versions.test.ts

示例5:

 .nock('https://buildpack-registry.heroku.com', (api: Scope) => {
   api
     .get('/buildpacks?in[namespace][]=heroku')
     .reply(200, [
       Fixture.buildpack({
         name: 'ruby',
         description: 'Official Heroku Buildpack for Ruby',
       })
     ])
 })
開發者ID:jimmyurl,項目名稱:cli,代碼行數:10,代碼來源:search.test.ts

示例6:

      .nock('https://buildpack-registry.heroku.com', (api: Scope) => {
        let buildpack = Fixture.buildpack({
          namespace: 'heroku',
          name: 'ruby',
          blob_url: 'https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/ruby.tgz',
        })

        api
          .get('/buildpacks/heroku%2Fruby')
          .reply(200, buildpack)
      })
開發者ID:jimmyurl,項目名稱:cli,代碼行數:11,代碼來源:add.test.ts


注:本文中的nock.Scope類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。