Skip to content

Commit

Permalink
Add test cases for more commands
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSaini101 committed Jan 4, 2025
1 parent 60390de commit 2c5b6d1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/models/SpecificationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ export class Specification {
} catch (error) {
throw new Error(`Invalid proxy URL: ${proxyUrl}`);
}
}

response = await fetch(targetUrl);
if (!response.ok) {
} else {
response = await fetch(targetUrl);
if (!response.ok) {
// console.log(response+" sdf")
throw new ErrorLoadingSpec('url', targetUrl);
throw new ErrorLoadingSpec('url', targetUrl);
}
}
} catch (error) {
console.log(error);
Expand Down
9 changes: 9 additions & 0 deletions test/integration/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ describe('convert', () => {
expect(ctx.stderr).to.equal('');
done();
});
test
.stderr()
.stdout()
.command(['convert', 'http://localhost:8080/dummySpec.yml --proxyHost=host --proxyPort=8080'])
.it('works when url is passed with proxyHost and proxyPort with invalid host ', (ctx, done) => {
expect(ctx.stdout).to.contain('');
expect(ctx.stderr).to.equal('error loading AsyncAPI document from url: Failed to download http://localhost:8080/dummySpec.yml --proxyHost=host --proxyPort=8080.\n');
done();
});
});

describe('with no arguments', () => {
Expand Down
9 changes: 9 additions & 0 deletions test/integration/optimize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ describe('optimize', () => {
expect(ctx.stderr).to.equal('');
done();
});
test
.stderr()
.stdout()
.command(['optimize', 'http://localhost:8080/dummySpec.yml --proxyHost=host --proxyPort=8080'])
.it('works when url is passed with proxyHost and proxyPort with invalid host ', (ctx, done) => {
expect(ctx.stdout).to.contain('');
expect(ctx.stderr).to.equal('error loading AsyncAPI document from url: Failed to download http://localhost:8080/dummySpec.yml --proxyHost=host --proxyPort=8080.\n');
done();
});
});

describe('with no arguments', () => {
Expand Down

0 comments on commit 2c5b6d1

Please sign in to comment.