@octokit/types#OctokitResponse TypeScript Examples

The following examples show how to use @octokit/types#OctokitResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts    From file-changes-action with MIT License 6 votes vote down vote up
octokitMock: OctokitMock = {
  paginate: (
    data: EndpointOptions,
    cb?: (response: OctokitResponse<any>) => Promise<any[]>
  ) => paginate(data, cb),
  pulls: {
    listFiles: Object.assign((data: EndpointOptions) => listFiles(data), {
      endpoint: {
        merge: (data: EndpointOptions) => endpointMerge(data)
      }
    })
  },
  repos: {
    compareCommits: Object.assign(
      (data: EndpointOptions) => compareCommits(data),
      {
        endpoint: {
          merge: (data: EndpointOptions) => endpointMerge(data)
        }
      }
    )
  }
}
Example #2
Source File: paginate.ts    From file-changes-action with MIT License 6 votes vote down vote up
fn = jest.fn(
  (
    data: EndpointOptions,
    cb?: (response: OctokitResponse<any>) => Promise<any[]>
  ) => {
    if (
      data.owner !== 'trilom' ||
      data.repo !== 'file-changes-action' ||
      (data.base && !data.head) ||
      (!data.base && data.head) ||
      // the github api doesn't seem to return an error
      // eslint-disable-next-line prefer-promise-reject-errors
      (!data.base && !data.head && !data.pull_number)
    )
      // eslint-disable-next-line prefer-promise-reject-errors
      return Promise.reject({name: 'HttpError', status: '404'})
    if (data.pull_number) {
      if (cb)
        return Promise.resolve(cb({data: prResponse} as OctokitResponse<any>))
      return Promise.resolve(prResponse)
    }
    if (cb)
      return Promise.resolve(cb({data: pushResponse} as OctokitResponse<any>))
    return Promise.resolve([pushResponse])
  }
)
Example #3
Source File: workflow.ts    From auto-cancel-redundant-workflow with MIT License 5 votes vote down vote up
cancelWorkflowRun = async(runId: number, octokit: Octokit, context: Context): Promise<OctokitResponse<{ [key: string]: unknown; }>> => octokit.rest.actions.cancelWorkflowRun({
  ...context.repo,
  'run_id': runId,
})
Example #4
Source File: listFiles.ts    From file-changes-action with MIT License 5 votes vote down vote up
fn = jest.fn((data: EndpointOptions) => {
  return Promise.resolve({
    data: OctokitPullsListFilesResponse
  } as OctokitResponse<any>)
})
Example #5
Source File: compareCommits.ts    From file-changes-action with MIT License 5 votes vote down vote up
fn = jest.fn((data: EndpointOptions) => {
  return Promise.resolve({
    data: {
      files: OctokitReposCompareCommitsResponse
    }
  } as OctokitResponse<any>)
})