Skip to content

Commit

Permalink
test: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Jan 11, 2022
1 parent e2c10be commit 2bd4199
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
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
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';

0 comments on commit 2bd4199

Please sign in to comment.