From afdbfc362191e7703c7883135387d0264d45682c Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Tue, 5 Sep 2023 11:18:26 -0500 Subject: [PATCH] chore: clean out some comment junk --- __tests__/helpers/get-api-mock.ts | 6 +- __tests__/helpers/get-gha-setup.ts | 2 - .../single-threaded/openapi/index.test.ts | 90 ------------------- vitest.single-threaded.config.ts | 4 - 4 files changed, 1 insertion(+), 101 deletions(-) diff --git a/__tests__/helpers/get-api-mock.ts b/__tests__/helpers/get-api-mock.ts index 8ce4cf2a4..f325d2e6d 100644 --- a/__tests__/helpers/get-api-mock.ts +++ b/__tests__/helpers/get-api-mock.ts @@ -26,16 +26,12 @@ export function getAPIMockWithVersionHeader(v: string) { }); } +// TODO: add ability to check for other headers function doHeadersMatch(headers: Headers) { - // const auth = headers.get('authorization'); - // const decodedAuth = auth ? Buffer.from(auth.replace(/^Basic /, ''), 'base64').toString('ascii') : ''; const userAgent = headers.get('user-agent'); return userAgent === getUserAgent(); } -// } = { method: 'get', path: '', status: 200, proxy: '' }, - -// TODO: add ability to check for other headers export function getAPIMockMSW( path: string = '', method: keyof typeof rest = 'get', diff --git a/__tests__/helpers/get-gha-setup.ts b/__tests__/helpers/get-gha-setup.ts index acfda18ec..eef5e9759 100644 --- a/__tests__/helpers/get-gha-setup.ts +++ b/__tests__/helpers/get-gha-setup.ts @@ -10,8 +10,6 @@ import * as getPkgVersion from '../../src/lib/getPkgVersion'; import getGitRemoteMock from './get-git-mock'; -// const testWorkingDir = process.cwd(); - /** * A helper function for setting up tests for our GitHub Action onboarding. * diff --git a/__tests__/single-threaded/openapi/index.test.ts b/__tests__/single-threaded/openapi/index.test.ts index abe158c67..3e4da6382 100644 --- a/__tests__/single-threaded/openapi/index.test.ts +++ b/__tests__/single-threaded/openapi/index.test.ts @@ -58,7 +58,6 @@ describe('rdme openapi (single-threaded)', () => { consoleInfoSpy.mockRestore(); consoleWarnSpy.mockRestore(); - // nock.cleanAll(); server.resetHandlers(); process.chdir(testWorkingDir); @@ -71,22 +70,6 @@ describe('rdme openapi (single-threaded)', () => { expect.assertions(5); const registryUUID = getRandomRegistryId(); - // const mock = getAPIMock() - // .get(`/api/v1/version/${version}`) - // .basicAuth({ user: key }) - // .reply(200, { version }) - // .post('/api/v1/api-registry', body => body.match('form-data; name="spec"')) - // .reply(201, { registryUUID, spec: { openapi: '3.0.0' } }); - - // const mockWithHeader = getAPIMockWithVersionHeader(version) - // .get('/api/v1/api-specification') - // .basicAuth({ user: key }) - // .reply(200, []) - // .post('/api/v1/api-specification', { registryUUID }) - // .delayConnection(1000) - // .basicAuth({ user: key }) - // .reply(201, { _id: 1 }, { location: exampleRefLocation }); - server.use( ...[ // TODO: basic auth @@ -128,26 +111,6 @@ describe('rdme openapi (single-threaded)', () => { let requestBody; const registryUUID = getRandomRegistryId(); - // const mock = getAPIMock() - // .get(`/api/v1/version/${version}`) - // .basicAuth({ user: key }) - // .reply(200, { version: '1.0.0' }) - // .post('/api/v1/api-registry', body => { - // requestBody = body.substring(body.indexOf('{'), body.lastIndexOf('}') + 1); - // requestBody = JSON.parse(requestBody); - - // return body.match('form-data; name="spec"'); - // }) - // .reply(201, { registryUUID, spec: { openapi: '3.0.0' } }); - - // const mockWithHeader = getAPIMockWithVersionHeader(version) - // .get('/api/v1/api-specification') - // .basicAuth({ user: key }) - // .reply(200, []) - // .post('/api/v1/api-specification', { registryUUID }) - // .basicAuth({ user: key }) - // .reply(201, { _id: 1 }, { location: exampleRefLocation }); - server.use( ...[ // TODO: basic auth @@ -190,18 +153,6 @@ describe('rdme openapi (single-threaded)', () => { expect.assertions(3); const registryUUID = getRandomRegistryId(); - // const mock = getAPIMock() - // .get(`/api/v1/version/${version}`) - // .basicAuth({ user: key }) - // .reply(200, { version }) - // .post('/api/v1/api-registry', body => body.match('form-data; name="spec"')) - // .reply(201, { registryUUID, spec: { openapi: '3.0.0' } }); - - // const mockWithHeader = getAPIMockWithVersionHeader(version) - // .get('/api/v1/api-specification') - // .basicAuth({ user: key }) - // .reply(200, []); - server.use( ...[ // TODO: basic auth @@ -263,21 +214,6 @@ describe('rdme openapi (single-threaded)', () => { prompts.inject([true, 'openapi-branch-workingdirectory', yamlFileName]); const registryUUID = getRandomRegistryId(); - // const mock = getAPIMock() - // .get(`/api/v1/version/${version}`) - // .basicAuth({ user: key }) - // .reply(200, { version: '1.0.0' }) - // .post('/api/v1/api-registry', body => body.match('form-data; name="spec"')) - // .reply(201, { registryUUID, spec: { openapi: '3.0.0' } }); - - // const mockWithHeader = getAPIMockWithVersionHeader(version) - // .get('/api/v1/api-specification') - // .basicAuth({ user: key }) - // .reply(200, []) - // .post('/api/v1/api-specification', { registryUUID }) - // .basicAuth({ user: key }) - // .reply(201, { _id: 1 }, { location: exampleRefLocation }); - server.use( ...[ // TODO: basic auth @@ -329,29 +265,6 @@ describe('rdme openapi (single-threaded)', () => { it('should contain request header with correct URL with working directory', async () => { expect.assertions(7); const registryUUID = getRandomRegistryId(); - // const mock = getAPIMock() - // .get(`/api/v1/version/${version}`) - // .basicAuth({ user: key }) - // .reply(200, { version: '1.0.0' }) - // .post('/api/v1/api-registry') - // .reply(201, { registryUUID, spec: { openapi: '3.0.0' } }); - - // const getMock = getAPIMockWithVersionHeader(version) - // .get('/api/v1/api-specification') - // .basicAuth({ user: key }) - // .reply(200, []); - - // const postMock = getAPIMock({ - // 'x-rdme-ci': 'GitHub Actions (test)', - // 'x-readme-source': 'cli-gh', - // 'x-readme-source-url': - // 'https://github.com/octocat/Hello-World/blob/ffac537e6cbbf934b08745a378932722df287a53/__tests__/__fixtures__/relative-ref-oas/petstore.json', - // 'x-readme-version': version, - // }) - // .post('/api/v1/api-specification', { registryUUID }) - // .basicAuth({ user: key }) - // .reply(201, { _id: 1 }, { location: exampleRefLocation }); - server.use( ...[ // TODO: basic auth @@ -389,9 +302,6 @@ describe('rdme openapi (single-threaded)', () => { }), ).resolves.toBe(successfulUpload(spec)); - // getMock.done(); - // postMock.done(); - // mock.done(); return after(); }); }); diff --git a/vitest.single-threaded.config.ts b/vitest.single-threaded.config.ts index 8fb4ec1ca..4a4b53cf3 100644 --- a/vitest.single-threaded.config.ts +++ b/vitest.single-threaded.config.ts @@ -4,10 +4,6 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { coverage: { - // branches: 80, - // functions: 80, - // lines: 90, - // statements: 90, reporter: 'text', }, exclude: ['**/dist/**', '**/node_modules/**', '**/__fixtures__/**', '**/helpers/**', '**/__snapshots__/**'],