Skip to content

Commit

Permalink
Merge branch 'v10-release' into kanad-2024-12-06/oas-v2-RM-11384
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta committed Dec 11, 2024
2 parents 17ff6b6 + 8488d2e commit a358d6d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions __tests__/helpers/get-api-mock.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import nock from 'nock';
import nock from "nock";

import config from '../../src/lib/config.js';
import { getUserAgent } from '../../src/lib/readmeAPIFetch.js';
import config from "../../src/lib/config.js";
import { getUserAgent } from "../../src/lib/readmeAPIFetch.js";

import { mockVersion } from './oclif.js';
import { mockVersion } from "./oclif.js";

/**
* Nock wrapper for ReadMe API v1 that adds required
Expand All @@ -12,7 +12,7 @@ import { mockVersion } from './oclif.js';
export function getAPIv1Mock(reqHeaders = {}) {
return nock(config.host.v1, {
reqheaders: {
'User-Agent': getUserAgent(),
"User-Agent": getUserAgent(),
...reqHeaders,
},
});
Expand All @@ -22,11 +22,11 @@ export function getAPIv1Mock(reqHeaders = {}) {
* Nock wrapper for ReadMe API v2 that adds required
* `user-agent` request header so it gets properly picked up by nock.
*/
export function getAPIv2Mock(reqHeaders: nock.Options['reqheaders'] = {}) {
export function getAPIv2Mock(reqHeaders: nock.Options["reqheaders"] = {}) {
return nock(config.host.v2, {
reqheaders: {
'User-Agent': ua => ua.startsWith(`rdme/${mockVersion}`),
'x-readme-source': 'cli',
"User-Agent": (ua) => ua.startsWith(`rdme/${mockVersion}`),
"x-readme-source": "cli",
...reqHeaders,
},
});
Expand All @@ -35,10 +35,10 @@ export function getAPIv2Mock(reqHeaders: nock.Options['reqheaders'] = {}) {
/**
* Variant of `getAPIv2Mock` for mocking a GitHub Actions environment.
*/
export function getAPIv2MockForGHA(reqHeaders: nock.Options['reqheaders'] = {}) {
export function getAPIv2MockForGHA(reqHeaders: nock.Options["reqheaders"] = {}) {
return getAPIv2Mock({
'User-Agent': ua => ua.startsWith(`rdme-github/${mockVersion}`),
'x-readme-source': 'cli-gh',
"User-Agent": (ua) => ua.startsWith(`rdme-github/${mockVersion}`),
"x-readme-source": "cli-gh",
...reqHeaders,
});
}

0 comments on commit a358d6d

Please sign in to comment.