Skip to content

Commit

Permalink
chore: adapt tests for v3
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya committed Aug 1, 2023
1 parent bc9d846 commit fc6bc7b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 16 additions & 3 deletions test/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ describe('parse()', function() {
channels: {}
};
const { document, diagnostics } = await parser.parse(documentRaw);
expect(document).toEqual(undefined);
expect(diagnostics.length > 0).toEqual(true);
expect(diagnostics[0].message).toContain('Version "3.0.0" is not supported');
expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
expect(diagnostics.length === 0).toEqual(true);
});

it('should parse invalid document', async function() {
Expand All @@ -51,6 +50,20 @@ describe('parse()', function() {
expect(diagnostics.length > 0).toEqual(true);
});

it('should parse invalid v3 document', async function() {
const documentRaw = {
asyncapi: '3.0.0',
not_a_valid_info_object: {
title: 'Invalid AsyncApi document',
version: '1.0',
},
};
const { document, diagnostics } = await parser.parse(documentRaw);

expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
expect(diagnostics.length === 0).toEqual(true); // Validation in v3 is still not enabled. This test will intentionally fail once that changes.
});

it('should return extras', async function() {
const documentRaw = {
asyncapi: '2.0.0',
Expand Down
6 changes: 3 additions & 3 deletions test/ruleset/formats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ describe('AsyncAPI format', () => {
{ formatVersion: '2.6.5', document: {asyncapi: '2.6.5'}, existsFormat: true, result: true },
{ formatVersion: '2.6.5', document: {asyncapi: '2.0.0'}, existsFormat: true, result: false },
{ formatVersion: '2.0.0', document: {asyncapi: '2.6.5'}, existsFormat: true, result: false },
{ formatVersion: '3.0.10', document: {asyncapi: '3.0.10'}, existsFormat: false, result: false },
{ formatVersion: '3.0.0', document: {openapi: '3.0.0'}, existsFormat: false, result: false },
{ formatVersion: '3.0.0', document: null, existsFormat: false, result: false },
{ formatVersion: '3.0.10', document: {asyncapi: '3.0.10'}, existsFormat: true, result: true },
{ formatVersion: '3.0.0', document: {openapi: '3.0.0'}, existsFormat: true, result: false },
{ formatVersion: '3.0.0', document: null, existsFormat: true, result: false },
{ formatVersion: '999.999.0', document: {}, existsFormat: false, result: false },
{ formatVersion: '19923.1.0', document: {}, existsFormat: false, result: false },
{ formatVersion: '2.99.0', document: {}, existsFormat: false, result: false },
Expand Down

0 comments on commit fc6bc7b

Please sign in to comment.