-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: npm script awareness, TS fixes, test env refactors (#659)
* refactor: rename internal test env vars - All internal env values (i.e. for testing CI or testing GitHub Action creation) are prefixed with `TEST_RDME_` - Renamed our `NODE_ENV` for our test from `test` to `rdme-test` - Created a little `isTest` helper to check whether we're running tests * chore(deps-dev): install keyv This isn't used, but we're seeing TS errors when users try to run `tsc` in a repo that contains `rdme` as a dep. Weirdly enough, installing this package fixes it. See: https://stackoverflow.com/q/74141618 * ci(prettier): only scan md files ESLint already covers JS/TS, so the duplicative check is not necessary * test: reorganize tests so they don't leak console warnings * feat: don't run createGHA workflow if invoked via npm lifecycle
- Loading branch information
1 parent
0278aa2
commit 05c34da
Showing
27 changed files
with
143 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,32 +92,17 @@ describe('cli', () => { | |
await expect(cli([])).resolves.toContain('OpenAPI / Swagger'); | ||
}); | ||
|
||
it('should add stored apiKey to opts', async () => { | ||
expect.assertions(1); | ||
const key = '123456'; | ||
const version = '1.0.0'; | ||
conf.set('apiKey', key); | ||
|
||
const versionMock = getAPIMock().get(`/api/v1/version/${version}`).basicAuth({ user: key }).reply(200, { version }); | ||
|
||
await expect(cli(['docs', `--version=${version}`])).rejects.toStrictEqual( | ||
new Error('No path provided. Usage `rdme docs <path> [options]`.') | ||
); | ||
|
||
conf.clear(); | ||
versionMock.done(); | ||
}); | ||
|
||
describe('logged-in user notifications', () => { | ||
describe('stored API key', () => { | ||
let consoleInfoSpy; | ||
const key = '123456'; | ||
const getCommandOutput = () => { | ||
return [consoleInfoSpy.mock.calls.join('\n\n')].filter(Boolean).join('\n\n'); | ||
}; | ||
|
||
beforeEach(() => { | ||
conf.set('email', '[email protected]'); | ||
conf.set('project', 'owlbert'); | ||
conf.set('apiKey', '123456'); | ||
conf.set('apiKey', key); | ||
consoleInfoSpy = jest.spyOn(console, 'info').mockImplementation(); | ||
}); | ||
|
||
|
@@ -126,6 +111,23 @@ describe('cli', () => { | |
conf.clear(); | ||
}); | ||
|
||
it('should add stored apiKey to opts', async () => { | ||
expect.assertions(1); | ||
const version = '1.0.0'; | ||
|
||
const versionMock = getAPIMock() | ||
.get(`/api/v1/version/${version}`) | ||
.basicAuth({ user: key }) | ||
.reply(200, { version }); | ||
|
||
await expect(cli(['docs', `--version=${version}`])).rejects.toStrictEqual( | ||
new Error('No path provided. Usage `rdme docs <path> [options]`.') | ||
); | ||
|
||
conf.clear(); | ||
versionMock.done(); | ||
}); | ||
|
||
it('should inform a logged in user which project is being updated', async () => { | ||
await expect(cli(['openapi', '--create', '--update'])).rejects.toThrow( | ||
'The `--create` and `--update` options cannot be used simultaneously. Please use one or the other!' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.