Skip to content

Commit

Permalink
Add stripAnsi usage for failing stdout color test
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-abbeduto-particle committed Oct 7, 2024
1 parent 329c24c commit 10dcf6f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cmd/whoami.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { withConsoleStubs } = require('../../test/lib/mocha-utils');
const settings = require('../../settings');
const ApiClient = require('../lib/api-client');
const WhoAmICommands = require('./whoami');
const stripAnsi = require('strip-ansi');


describe('Whoami Commands', () => {
Expand All @@ -25,8 +26,7 @@ describe('Whoami Commands', () => {
sandbox.restore();
});

// We don't need to monitor stdout here, but the stub also sets TTY to false forcing color consistency locally and in CI
it('fails when user is signed-out', withConsoleStubs(sandbox, () => {
it('fails when user is signed-out', () => {
sandbox.stub(ApiClient.prototype, '_access_token').get(() => null);
const whoAmI = whoAmICommands();

Expand All @@ -35,9 +35,9 @@ describe('Whoami Commands', () => {
throw new Error('expected promise to be rejected');
})
.catch(error => {
expect(error).to.have.property('message', 'You\'re not logged in. Please login using [1m[36mparticle cloud login[39m[22m before using this command');
expect(stripAnsi(error.message)).to.eql('You\'re not logged in. Please login using particle cloud login before using this command');
});
}));
});

it('fails when token is invalid', () => {
sandbox.stub(ApiClient.prototype, 'getUser').throws();
Expand Down

0 comments on commit 10dcf6f

Please sign in to comment.