Skip to content

Commit

Permalink
chore: clean out some comment junk
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta committed Sep 5, 2023
1 parent 9c7f2f0 commit afdbfc3
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 101 deletions.
6 changes: 1 addition & 5 deletions __tests__/helpers/get-api-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 0 additions & 2 deletions __tests__/helpers/get-gha-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
90 changes: 0 additions & 90 deletions __tests__/single-threaded/openapi/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ describe('rdme openapi (single-threaded)', () => {
consoleInfoSpy.mockRestore();
consoleWarnSpy.mockRestore();

// nock.cleanAll();
server.resetHandlers();

process.chdir(testWorkingDir);
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -389,9 +302,6 @@ describe('rdme openapi (single-threaded)', () => {
}),
).resolves.toBe(successfulUpload(spec));

// getMock.done();
// postMock.done();
// mock.done();
return after();
});
});
Expand Down
4 changes: 0 additions & 4 deletions vitest.single-threaded.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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__/**'],
Expand Down

0 comments on commit afdbfc3

Please sign in to comment.