-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: commands into command classes #424
Changes from all commits
70557ac
3d394d6
c6bf6da
e0521be
eff1284
aa36dd9
ab02e04
717ed68
7b123cd
e2c10be
2bd4199
517d7ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
coverage | ||
node_modules/ | ||
coverage/ | ||
swagger.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We technically shouldn’t need this since a successful test run will result in this file being deleted properly… but I suppose doesn’t hurt! |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
const nock = require('nock'); | ||
const config = require('config'); | ||
const configStore = require('../../src/lib/configstore'); | ||
const cmd = require('../../src/cmds/login'); | ||
const Command = require('../../src/cmds/login'); | ||
const APIError = require('../../src/lib/apiError'); | ||
|
||
const cmd = new Command(); | ||
|
||
const email = '[email protected]'; | ||
const password = '123456'; | ||
const project = 'subdomain'; | ||
|
@@ -33,6 +35,7 @@ describe('rdme login', () => { | |
const mock = nock(config.get('host')).post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); | ||
|
||
await expect(cmd.run({ email, password, project })).resolves.toMatchSnapshot(); | ||
|
||
mock.done(); | ||
|
||
expect(configStore.get('apiKey')).toBe(apiKey); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ const config = require('config'); | |
const promptHandler = require('../../src/lib/prompts'); | ||
const APIError = require('../../src/lib/apiError'); | ||
|
||
const versions = require('../../src/cmds/versions'); | ||
const createVersion = require('../../src/cmds/versions/create'); | ||
const deleteVersion = require('../../src/cmds/versions/delete'); | ||
const updateVersion = require('../../src/cmds/versions/update'); | ||
const VersionsCommand = require('../../src/cmds/versions'); | ||
const CreateVersionCommand = require('../../src/cmds/versions/create'); | ||
const DeleteVersionCommand = require('../../src/cmds/versions/delete'); | ||
const UpdateVersionCommand = require('../../src/cmds/versions/update'); | ||
|
||
const key = 'API_KEY'; | ||
const version = '1.0.0'; | ||
|
@@ -40,6 +40,8 @@ describe('rdme versions*', () => { | |
afterEach(() => nock.cleanAll()); | ||
|
||
describe('rdme versions', () => { | ||
const versions = new VersionsCommand(); | ||
|
||
it('should error if no api key provided', () => { | ||
return expect(versions.run({})).rejects.toStrictEqual( | ||
new Error('No project API key provided. Please use `--key`.') | ||
|
@@ -52,7 +54,9 @@ describe('rdme versions*', () => { | |
.basicAuth({ user: key }) | ||
.reply(200, [versionPayload, version2Payload]); | ||
|
||
await expect(versions.run({ key })).resolves.toMatchSnapshot(); | ||
const table = await versions.run({ key }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted this back to using these two assertions because the |
||
expect(table).toContain(version); | ||
expect(table).toContain(version2); | ||
mockRequest.done(); | ||
}); | ||
|
||
|
@@ -73,7 +77,9 @@ describe('rdme versions*', () => { | |
.basicAuth({ user: key }) | ||
.reply(200, versionPayload); | ||
|
||
await expect(versions.run({ key, version })).resolves.toMatchSnapshot(); | ||
const table = await versions.run({ key, version }); | ||
expect(table).toContain(version); | ||
expect(table).not.toContain(version2); | ||
mockRequest.done(); | ||
}); | ||
|
||
|
@@ -90,6 +96,8 @@ describe('rdme versions*', () => { | |
}); | ||
|
||
describe('rdme versions:create', () => { | ||
const createVersion = new CreateVersionCommand(); | ||
|
||
it('should error if no api key provided', () => { | ||
return createVersion.run({}).catch(err => { | ||
expect(err.message).toBe('No project API key provided. Please use `--key`.'); | ||
|
@@ -143,6 +151,8 @@ describe('rdme versions*', () => { | |
}); | ||
|
||
describe('rdme versions:delete', () => { | ||
const deleteVersion = new DeleteVersionCommand(); | ||
|
||
it('should error if no api key provided', () => { | ||
return expect(deleteVersion.run({})).rejects.toStrictEqual( | ||
new Error('No project API key provided. Please use `--key`.') | ||
|
@@ -185,6 +195,8 @@ describe('rdme versions*', () => { | |
}); | ||
|
||
describe('rdme versions:update', () => { | ||
const updateVersion = new UpdateVersionCommand(); | ||
|
||
it('should error if no api key provided', () => { | ||
return expect(updateVersion.run({})).rejects.toStrictEqual( | ||
new Error('No project API key provided. Please use `--key`.') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Chalk has trouble with Jest sometimes in test snapshots so we're disabling colorization here for all tests. | ||
// The `chalk` and `colors` libraries have trouble with Jest sometimes in test snapshots so we're disabling | ||
// colorization here for all tests. | ||
// https://github.com/chalk/supports-color/issues/106 | ||
process.env.FORCE_COLOR = 0; | ||
|
||
process.env.NODE_ENV = 'testing'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanna add a small comment explaining why we need this?