Skip to content

Commit

Permalink
Fix sonar issues and added one more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSaini101 committed Nov 19, 2024
1 parent 7a9f975 commit 4d8faed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/commands/pretty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import { ValidationError } from '../core/errors/validation-error';
import { prettyFlags } from '../core/flags/pretty.flags';

export default class Pretty extends Command {
static description = 'Format AsyncAPI specification file';
static readonly description = 'Format AsyncAPI specification file';

static examples = [
static readonly examples = [
'asyncapi pretty ./asyncapi.yaml',
'asyncapi pretty ./asyncapi.yaml --output formatted-asyncapi.yaml',
];

static flags = prettyFlags();
static readonly flags = prettyFlags();

static args = {
static readonly args = {
'spec-file': Args.string({description: 'spec path, url, or context-name', required: true}),
};

Expand Down
13 changes: 13 additions & 0 deletions test/integration/pretty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { expect } from '@oclif/test';

const testHelper = new TestHelper();
const badFormatPath = './test/fixtures/asyncapi_v1.yml';
const validFormatPath = './test/fixtures/asyncapiValid_v1.yml';

describe('pretty', () => {
describe('with file paths', () => {
Expand Down Expand Up @@ -34,5 +35,17 @@ describe('pretty', () => {
expect(ctx.stderr).to.equal('');
done();
});

test
.stderr()
.stdout()
.command(['pretty', badFormatPath ,'-o', validFormatPath])
.it('should log the information file has been beautified', (ctx, done) => {
expect(ctx.stdout).to.contain(
`Asyncapi document has been beautified ${validFormatPath}`,
);
expect(ctx.stderr).to.equal('');
done();
});
});
});

0 comments on commit 4d8faed

Please sign in to comment.