|
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'; |
3 | 3 | import { Parser } from '@asyncapi/parser'; |
4 | 4 | import { OpenAPISchemaParser } from '../src'; |
5 | 5 |
|
@@ -68,12 +68,12 @@ describe('OpenAPISchemaParser', function () { |
68 | 68 | it('should parse valid AsyncAPI', async function() { |
69 | 69 | const { document, diagnostics } = await coreParser.parse(inputWithValidAsyncAPI); |
70 | 70 | 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); |
73 | 73 | }); |
74 | 74 |
|
75 | 75 | it('should parse valid AsyncAPI3', async function() { |
76 | | - const { document, diagnostics } = await coreParser.parse(inputWithValidAsyncAPI3); |
| 76 | + const { diagnostics } = await coreParser.parse(inputWithValidAsyncAPI3); |
77 | 77 | expect(diagnostics).toHaveLength(0); |
78 | 78 | }); |
79 | 79 |
|
@@ -147,17 +147,17 @@ describe('OpenAPISchemaParser', function () { |
147 | 147 | // Check that the return value of parse() is the expected JSON Schema. |
148 | 148 | expect(result).toEqual(JSON.parse(expectedOutput)); |
149 | 149 | } |
| 150 | +}); |
150 | 151 |
|
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 | + })); |
156 | 157 |
|
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 | +} |
161 | 161 |
|
162 | 162 | function toParseInput(raw: string): ParseSchemaInput | ValidateSchemaInput { |
163 | 163 | const message = JSON.parse(raw); |
|
0 commit comments