Skip to content

Commit

Permalink
test: remove test coverage around --key flag
Browse files Browse the repository at this point in the history
these tests were duplicative and felt out of scope of the command tests. will add proper top-level coverage for this!

also, couldn't figure out a good way to add coverage in commands without running into weird flakiness and race conditions.
  • Loading branch information
kanadgupta committed Jan 9, 2024
1 parent efb7f9f commit 4e92554
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 174 deletions.
13 changes: 0 additions & 13 deletions __tests__/cmds/categories/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ describe('rdme categories:create', () => {

afterEach(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should error if no title provided', () => {
return expect(run(['--key', key])).rejects.toThrow('Missing 1 required arg:\ntitle');
});
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/categories/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ describe('rdme categories', () => {

afterEach(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should return all categories for a single page', async () => {
const getMock = getAPIMockWithVersionHeader(version)
.persist()
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/changelogs/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ describe('rdme changelogs', () => {

afterAll(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should error if no path provided', () => {
return expect(run(['--key', key])).rejects.toThrow('Missing 1 required arg:\npath');
});
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/changelogs/single.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ describe('rdme changelogs (single)', () => {

afterAll(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should error if no file path provided', () => {
return expect(run(['--key', key])).rejects.toThrow('Missing 1 required arg:\npath');
});
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/custompages/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ describe('rdme custompages', () => {

afterAll(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should error if no path provided', () => {
return expect(run(['--key', key])).rejects.toThrow('Missing 1 required arg:\npath');
});
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/custompages/single.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ describe('rdme custompages (single)', () => {

afterAll(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should error if no file path provided', () => {
return expect(run(['--key', key])).rejects.toThrow('Missing 1 required arg:\npath');
});
Expand Down
11 changes: 0 additions & 11 deletions __tests__/cmds/docs/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ describe('rdme docs', () => {

afterAll(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should successfully log in user via prompts if API key is not provided', async () => {
const email = '[email protected]';
const password = 'pass123';
Expand Down Expand Up @@ -623,10 +616,6 @@ describe('rdme docs', () => {

afterEach(afterGHAEnv);

it('should error in CI if no API key provided', () => {
return expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
});

it('should sync new docs directory with correct headers', async () => {
const slug = 'new-doc';
const id = '1234';
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/docs/prune.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ describe('rdme docs:prune', () => {

afterAll(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should error if no folder provided', () => {
return expect(run(['--key', key, '--version', version])).rejects.rejects.toThrow('Missing 1 required arg:\nfolder');
});
Expand Down
11 changes: 0 additions & 11 deletions __tests__/cmds/docs/single.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ describe('rdme docs (single)', () => {

afterAll(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error if no file path provided', () => {
return expect(run(['--key', key, '--version', version])).rejects.toThrow('Missing 1 required arg:\npath');
});
Expand Down Expand Up @@ -357,10 +350,6 @@ describe('rdme docs (single)', () => {

afterEach(afterGHAEnv);

it('should error in CI if no API key provided', () => {
return expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
});

it('should sync new doc with correct headers', async () => {
const slug = 'new-doc';
const id = '1234';
Expand Down
9 changes: 0 additions & 9 deletions __tests__/cmds/openapi/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,6 @@ describe('rdme openapi', () => {
});

describe('error handling', () => {
it('should prompt for login if no API key provided', () => {
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
return expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
});

it('should error if `--create` and `--update` flags are passed simultaneously', () => {
return expect(run(['--key', key, '--create', '--update'])).rejects.toThrow(
'--update=true cannot also be provided when using --create',
Expand Down Expand Up @@ -1196,10 +1191,6 @@ describe('rdme openapi', () => {

afterEach(afterGHAEnv);

it('should error in CI if no API key provided', () => {
return expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
});

it('should error out if multiple possible spec matches were found', () => {
return expect(run(['--key', key, '--version', version])).rejects.toStrictEqual(
new Error('Multiple API definitions found in current directory. Please specify file.'),
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/versions/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ describe('rdme versions:create', () => {

afterEach(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should error if no version provided', () => {
return expect(run(['--key', key])).rejects.toThrow('Missing 1 required arg:\nversion');
});
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/versions/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ describe('rdme versions:delete', () => {

afterEach(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should delete a specific version', async () => {
const mockRequest = getAPIMock()
.delete(`/api/v1/version/${version}`)
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/versions/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@ describe('rdme versions', () => {

afterEach(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should make a request to get a list of existing versions', async () => {
const mockRequest = getAPIMock()
.get('/api/v1/version')
Expand Down
13 changes: 0 additions & 13 deletions __tests__/cmds/versions/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ describe('rdme versions:update', () => {

afterEach(() => nock.cleanAll());

it('should prompt for login if no API key provided', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
prompts.inject(['this-is-not-an-email', 'password', 'subdomain']);
await expect(run()).rejects.toStrictEqual(new Error('You must provide a valid email address.'));
consoleInfoSpy.mockRestore();
});

it('should error in CI if no API key provided', async () => {
process.env.TEST_RDME_CI = 'true';
await expect(run()).rejects.toStrictEqual(new Error('No project API key provided. Please use `--key`.'));
delete process.env.TEST_RDME_CI;
});

it('should update a specific version object', async () => {
const versionToChange = '1.1.0';
const renamedVersion = '1.1.0-update';
Expand Down

0 comments on commit 4e92554

Please sign in to comment.