Skip to content

Commit

Permalink
fix codesmells
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Sep 27, 2023
1 parent 1cadff2 commit c60f7c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class Generator {
* @param {Object} [parseOptions={}] AsyncAPI Parser parse options. Check out {@link https://www.github.com/asyncapi/parser-js|@asyncapi/parser} for more information. Remember to use the right options to the right parser depending on the template you are using.
* @return {Promise}
*/
//NOSONAR
// eslint-disable-next-line sonarjs/cognitive-complexity
async generate(asyncapiDocument, parseOptions = {}) {
const isAlreadyParsedDocument = isAsyncAPIDocument(asyncapiDocument);
const isParsableCompatible = asyncapiDocument || typeof asyncapiString === 'string';
Expand Down
3 changes: 3 additions & 0 deletions test/generator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ describe('Generator', () => {
it('calls this.generate', async () => {
const gen = new Generator('testTemplate', __dirname);
gen.generate = generateMock;
//NOSONAR
await gen.generateFromString(dummyYAML);

expect(generateMock).toHaveBeenCalled();
Expand All @@ -280,12 +281,14 @@ describe('Generator', () => {
it('fails if asyncapiString is not provided', async () => {
const gen = new Generator('testTemplate', __dirname);
gen.generate = generateMock;
//NOSONAR
expect(() => gen.generateFromString()).rejects.toThrow('Parameter "asyncapiString" must be a non-empty string.');
});

it('fails if asyncapiString is not a string', async () => {
const gen = new Generator('testTemplate', __dirname);
gen.generate = generateMock;
//NOSONAR
expect(() => gen.generateFromString(1)).rejects.toThrow('Parameter "asyncapiString" must be a non-empty string.');
});
});
Expand Down

0 comments on commit c60f7c9

Please sign in to comment.