MCPcopy Create free account
hub / github.com/angular/dev-infra / interceptBranchVersionRequest

Function interceptBranchVersionRequest

ng-dev/pr/merge/integration.spec.ts:66–80  ·  view source on GitHub ↗

* Mocks a branch `package.json` version API request. * https://docs.github.com/en/rest/reference/repos#get-repository-content.

(
    branchName: string,
    version: string,
    opts?: {exceptionalMinor: boolean},
  )

Source from the content-addressed store, hash-verified

64 * https://docs.github.com/en/rest/reference/repos#get-repository-content.
65 */
66 function interceptBranchVersionRequest(
67 branchName: string,
68 version: string,
69 opts?: {exceptionalMinor: boolean},
70 ) {
71 const pkgJson: PackageJson = {version};
72 if (opts?.exceptionalMinor) {
73 pkgJson[exceptionalMinorPackageIndicator] = true;
74 }
75
76 nock(getRepoApiRequestUrl())
77 .get('/contents/%2Fpackage.json')
78 .query((params) => params['ref'] === branchName)
79 .reply(200, {content: Buffer.from(JSON.stringify(pkgJson)).toString('base64')});
80 }
81
82 /** Fakes a prompt confirm question with the given value. */
83 function fakePromptConfirmValue(returnValue: boolean) {

Callers 2

installMocksFunction · 0.70

Calls 5

getRepoApiRequestUrlFunction · 0.70
replyMethod · 0.45
getMethod · 0.45
toStringMethod · 0.45
stringifyMethod · 0.45

Tested by

no test coverage detected