Skip to content

Commit f27f3dd

Browse files
committed
fix tests
1 parent ced031c commit f27f3dd

File tree

6 files changed

+123
-29
lines changed

6 files changed

+123
-29
lines changed

package-lock.json

Lines changed: 87 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"prepublishOnly": "npm run generate:assets"
4444
},
4545
"dependencies": {
46-
"@asyncapi/specs": "^6.11.0",
46+
"@asyncapi/specs": "https://github.com/derberg/asyncapi-node.git#9ed4cfeddea95ad19b8fbafcfb36cf2e17dfda78",
4747
"@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0",
4848
"@stoplight/json": "3.21.0",
4949
"@stoplight/json-ref-readers": "^1.2.2",

packages/parser/test/custom-operations/apply-traits-v3.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('custom operations - apply traits v3', function() {
99

1010
it('should apply traits to operations', async function() {
1111
const documentRaw = {
12-
asyncapi: '3.1.0',
12+
asyncapi: '3.0.0',
1313
info: {
1414
title: 'Valid AsyncApi document',
1515
version: '1.0',
@@ -50,7 +50,9 @@ describe('custom operations - apply traits v3', function() {
5050
}
5151
};
5252
const { document, diagnostics } = await parser.parse(documentRaw);
53-
expect(diagnostics).toHaveLength(0);
53+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
54+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
55+
expect(filteredDiagnostics).toHaveLength(0);
5456

5557
const v3Document = document as AsyncAPIDocumentV3;
5658
expect(v3Document).toBeInstanceOf(AsyncAPIDocumentV3);
@@ -297,7 +299,9 @@ describe('custom operations - apply traits v3', function() {
297299

298300
beforeAll(async () => {
299301
const { document, diagnostics } = await parser.parse(documentRaw);
300-
expect(diagnostics.length).toEqual(0);
302+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
303+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
304+
expect(filteredDiagnostics.length).toEqual(0);
301305
v3Document = document as AsyncAPIDocumentV3;
302306
});
303307

packages/parser/test/custom-operations/parse-schema-v3.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ describe('custom operations for v3 - parse schemas', function() {
6363
}
6464
};
6565
const { document, diagnostics } = await parser.parse(documentRaw);
66+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
67+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
6668

6769
expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
68-
expect(diagnostics.length === 0).toEqual(true);
70+
expect(filteredDiagnostics.length === 0).toEqual(true);
6971

7072
expect(((document?.json()?.channels?.channel as v3.ChannelObject).messages?.message as v3.MessageObject)?.payload?.schema).toEqual({ type: 'object', 'x-parser-schema-id': '<anonymous-schema-1>' });
7173
expect(((((document?.json() as any).operations?.operation as v3.OperationObject).channel as v3.ChannelObject)?.messages?.message as v3.MessageObject)?.payload?.schema).toEqual({ type: 'object', 'x-parser-schema-id': '<anonymous-schema-1>' });
@@ -97,9 +99,11 @@ describe('custom operations for v3 - parse schemas', function() {
9799
}
98100
};
99101
const { document, diagnostics } = await parser.parse(documentRaw);
100-
102+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
103+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
104+
101105
expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
102-
expect(diagnostics.length === 0).toEqual(true);
106+
expect(filteredDiagnostics.length === 0).toEqual(true);
103107

104108
expect(((document?.json()?.channels?.channel as v3.ChannelObject).messages?.message as v3.MessageObject)?.payload).toEqual({ type: 'object', 'x-parser-schema-id': '<anonymous-schema-1>' });
105109
});

packages/parser/test/parse.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ describe('parse()', function () {
3636
channels: {},
3737
};
3838
const { document, diagnostics } = await parser.parse(documentRaw);
39+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
40+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
3941
expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
40-
expect(diagnostics.length === 0).toEqual(true);
42+
expect(filteredDiagnostics.length === 0).toEqual(true);
4143
});
4244

4345
it('should parse invalid document', async function () {
@@ -361,9 +363,11 @@ describe('parse()', function () {
361363
description: Email of the user`;
362364

363365
const { document, diagnostics } = await parser.parse(documentRaw);
366+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
367+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
364368

365369
expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
366-
expect(diagnostics.length === 0).toEqual(true);
370+
expect(filteredDiagnostics.length === 0).toEqual(true);
367371
});
368372

369373
it('should parse valid v3 JSON document in JSON format', async function () {
@@ -420,19 +424,23 @@ describe('parse()', function () {
420424
};
421425

422426
const { document, diagnostics } = await parser.parse(documentRaw);
427+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
428+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
423429

424430
expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
425-
expect(diagnostics.length === 0).toEqual(true);
431+
expect(filteredDiagnostics.length === 0).toEqual(true);
426432
});
427433

428434
it('should parse valid v3 JSON document after JSON.stringify()', async function () {
429435
const documentRaw =
430436
'{\n "asyncapi": "3.0.0",\n "info": {\n "title": "Account Service",\n "version": "1.0.0",\n "description": "This service is in charge of processing user signups"\n },\n "channels": {\n "userSignedup": {\n "address": "user/signedup",\n "messages": {\n "UserSignedUp": {\n "$ref": "#/components/messages/UserSignedUp"\n }\n }\n }\n },\n "operations": {\n "sendUserSignedup": {\n "action": "send",\n "channel": {\n "$ref": "#/channels/userSignedup"\n },\n "messages": [\n {\n "$ref": "#/channels/userSignedup/messages/UserSignedUp"\n }\n ]\n }\n },\n "components": {\n "messages": {\n "UserSignedUp": {\n "payload": {\n "type": "object",\n "properties": {\n "displayName": {\n "type": "string",\n "description": "Name of the user"\n },\n "email": {\n "type": "string",\n "format": "email",\n "description": "Email of the user"\n }\n }\n }\n }\n }\n }\n}\n';
431437

432438
const { document, diagnostics } = await parser.parse(documentRaw);
439+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
440+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
433441

434442
expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
435-
expect(diagnostics.length === 0).toEqual(true);
443+
expect(filteredDiagnostics.length === 0).toEqual(true);
436444
});
437445

438446
it('should not parse invalid v3 YAML document and give error in line 153 (#936)', async function () {
@@ -767,9 +775,11 @@ components:
767775
bindingVersion: '0.3.0'`;
768776

769777
const { document, diagnostics } = await parser.parse(documentRaw);
778+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
779+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
770780

771781
expect(document).not.toBeInstanceOf(AsyncAPIDocumentV3);
772-
expect(diagnostics[0].range.start.line === 153).toEqual(true);
782+
expect(filteredDiagnostics[0].range.start.line === 153).toEqual(true);
773783
});
774784

775785
it('should not parse invalid v3 JSON document and give error in line 236 (#936)', async function () {
@@ -1269,8 +1279,10 @@ components:
12691279
};
12701280

12711281
const { document, diagnostics } = await parser.parse(documentRaw);
1282+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
1283+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
12721284

12731285
expect(document).not.toBeInstanceOf(AsyncAPIDocumentV3);
1274-
expect(diagnostics[0].range.start.line === 236).toEqual(true);
1286+
expect(filteredDiagnostics[0].range.start.line === 236).toEqual(true);
12751287
});
12761288
});

packages/parser/test/validate.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ describe('validate()', function() {
9292
}
9393
};
9494
const { document, diagnostics } = await parser.parse(documentRaw, { validateOptions: { allowedSeverity: { warning: false } } });
95-
expect(diagnostics).toHaveLength(0);
95+
// Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release
96+
const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version');
97+
expect(filteredDiagnostics).toHaveLength(0);
9698
expect(document).toBeInstanceOf(AsyncAPIDocument);
9799
});
98100
});

0 commit comments

Comments
 (0)