当前位置: 首页>>代码示例>>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;未经允许,请勿转载。