Skip to content
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

Merged
merged 12 commits into from
Jan 12, 2022
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
coverage
node_modules/
coverage/
swagger.json
Copy link
Member

Choose a reason for hiding this comment

The 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!

5 changes: 5 additions & 0 deletions __tests__/cmds/__snapshots__/login.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rdme login should post to /login on the API 1`] = `"Successfully logged in as [email protected] to the subdomain project."`;

exports[`rdme login should send 2fa token if provided 1`] = `"Successfully logged in as [email protected] to the subdomain project."`;
9 changes: 2 additions & 7 deletions __tests__/cmds/login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ describe('rdme login', () => {

const mock = nock(config.get('host')).post('/api/v1/login', { email, password, project }).reply(200, { apiKey });

const output = await cmd.run({ email, password, project });
expect(output).toContain('[email protected]');
expect(output).toContain('subdomain');
await expect(cmd.run({ email, password, project })).resolves.toMatchSnapshot();

mock.done();

Expand Down Expand Up @@ -81,10 +79,7 @@ describe('rdme login', () => {
.post('/api/v1/login', { email, password, project, token })
.reply(200, { apiKey: '123' });

const output = await cmd.run({ email, password, project, token });
expect(output).toContain('[email protected]');
expect(output).toContain('subdomain');

await expect(cmd.run({ email, password, project, token })).resolves.toMatchSnapshot();
mock.done();
});

Expand Down
4 changes: 4 additions & 0 deletions __tests__/set-node-env.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
// The `chalk` and `colors` libraries have trouble with Jest sometimes in test snapshots so we're disabling
// colorization here for all tests.
process.env.FORCE_COLOR = 0;

process.env.NODE_ENV = 'testing';