Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya committed Aug 1, 2023
1 parent c0a4c19 commit b32e07b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('parse()', function() {
const { document, diagnostics } = await parser.parse(documentRaw);
expect(document).toEqual(undefined);
expect(diagnostics.length > 0).toEqual(true);
expect(diagnostics[0].message).toContain('Unsupported AsyncAPI version: 3.0.0');
expect(diagnostics[0].message).toContain('Version "3.0.0" is not supported');
});

it('should parse invalid document', async function() {
Expand Down
11 changes: 8 additions & 3 deletions test/ruleset/formats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { schemas } from '@asyncapi/specs';
import { AsyncAPIFormats, Formats } from '../../src/ruleset/formats';
import { getSemver } from '../../src/utils';

import type { Format } from '@stoplight/spectral-core';

describe('AsyncAPI format', () => {
describe('Recognizes versions', () => {
const testCases = [
Expand All @@ -17,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: 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: '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: '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 Expand Up @@ -54,6 +56,9 @@ describe('AsyncAPIFormats collection', () => {
});

it('Filters by major version', () => {
const formats = AsyncAPIFormats;
formats.set('999.0.0', (_: unknown): boolean => true);

const filteredMajorVersion = '2';
const previousLenght = AsyncAPIFormats.formats().length;
const filteredFormats = AsyncAPIFormats.filterByMajorVersions([filteredMajorVersion]);
Expand Down

0 comments on commit b32e07b

Please sign in to comment.