Skip to content

Commit 9d360fc

Browse files
committed
apply SonarQube recommendations
1 parent bd2157b commit 9d360fc

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

test/parser.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as fs from 'fs';
2-
import * as path from 'path';
1+
import * as fs from 'node:fs';
2+
import * as path from 'node:path';
33
import { Parser } from '@asyncapi/parser';
44
import { OpenAPISchemaParser } from '../src';
55

@@ -68,12 +68,12 @@ describe('OpenAPISchemaParser', function () {
6868
it('should parse valid AsyncAPI', async function() {
6969
const { document, diagnostics } = await coreParser.parse(inputWithValidAsyncAPI);
7070
expect(filterDiagnostics(diagnostics, 'asyncapi2-schemas')).toHaveLength(0);
71-
doParseCoreTest((document?.json()?.channels?.myChannel?.publish?.message as any)?.payload, outputWithValidOpenApi3);
72-
doParseCoreTest((document?.json()?.components?.messages?.testMessage as any)?.payload, outputWithValidOpenApi3);
71+
await doParseCoreTest((document?.json()?.channels?.myChannel?.publish?.message as any)?.payload, outputWithValidOpenApi3);
72+
await doParseCoreTest((document?.json()?.components?.messages?.testMessage as any)?.payload, outputWithValidOpenApi3);
7373
});
7474

7575
it('should parse valid AsyncAPI3', async function() {
76-
const { document, diagnostics } = await coreParser.parse(inputWithValidAsyncAPI3);
76+
const { diagnostics } = await coreParser.parse(inputWithValidAsyncAPI3);
7777
expect(diagnostics).toHaveLength(0);
7878
});
7979

@@ -147,17 +147,17 @@ describe('OpenAPISchemaParser', function () {
147147
// Check that the return value of parse() is the expected JSON Schema.
148148
expect(result).toEqual(JSON.parse(expectedOutput));
149149
}
150+
});
150151

151-
async function doParseCoreTest(parsedSchema: any, expectedOutput: string) {
152-
const result = JSON.parse(JSON.stringify(parsedSchema, (field: string, value: unknown) => {
153-
if (field === 'x-parser-schema-id') return;
154-
return value;
155-
}));
152+
async function doParseCoreTest(parsedSchema: any, expectedOutput: string) {
153+
const result = JSON.parse(JSON.stringify(parsedSchema, (field: string, value: unknown) => {
154+
if (field === 'x-parser-schema-id') return;
155+
return value;
156+
}));
156157

157-
// Check that the return value of parse() is the expected JSON Schema.
158-
expect(result).toEqual(JSON.parse(expectedOutput));
159-
}
160-
});
158+
// Check that the return value of parse() is the expected JSON Schema.
159+
expect(result).toEqual(JSON.parse(expectedOutput));
160+
}
161161

162162
function toParseInput(raw: string): ParseSchemaInput | ValidateSchemaInput {
163163
const message = JSON.parse(raw);

0 commit comments

Comments
 (0)